Skip to content

Instantly share code, notes, and snippets.

@belocer
Created February 3, 2021 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belocer/8b5f2ac08f0645c4d02cb562c0f7344a to your computer and use it in GitHub Desktop.
Save belocer/8b5f2ac08f0645c4d02cb562c0f7344a to your computer and use it in GitHub Desktop.
Самописный map
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