Functional Programming Examples using JavaScript