Created
February 3, 2021 06:50
-
-
Save belocer/8b5f2ac08f0645c4d02cb562c0f7344a to your computer and use it in GitHub Desktop.
Самописный map
This file contains 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
const names = ['Denis', 'Ivan', 'Maks', 'Olga'] | |
function mapArray(arr, fn) { | |
let res = [] | |
for (let i = 0; i < arr.length; i++) { | |
res.push(fn(arr[i])); | |
} | |
return res; | |
} | |
function nameLength(el) { | |
console.log(el) | |
return el | |
} | |
mapArray(names, nameLength) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment