Skip to content

Instantly share code, notes, and snippets.

@egrueter-dev
Last active March 4, 2017 02:54
Show Gist options
  • Save egrueter-dev/7feea7379cc25b9ccc34d3de6746ba43 to your computer and use it in GitHub Desktop.
Save egrueter-dev/7feea7379cc25b9ccc34d3de6746ba43 to your computer and use it in GitHub Desktop.
functional-programming1
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