Last active
March 4, 2017 02:54
-
-
Save egrueter-dev/7feea7379cc25b9ccc34d3de6746ba43 to your computer and use it in GitHub Desktop.
functional-programming1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapForEach(arr, fn) { | |
const newArr = []; | |
for (let i=0; i < arr.length; i++) { | |
newArr.push( | |
fn(arr[i]) | |
); | |
}; | |
return newArr; | |
} | |
const arr1 = [1, 2, 3] | |
console.log(arr1); | |
const arr2 = mapForEach(arr1, (item) => { | |
return item * 2 | |
}); | |
console.log(arr2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment