Skip to content

Instantly share code, notes, and snippets.

@belocer

belocer/js.js

Created Feb 3, 2021
Embed
What would you like to do?
Самописный 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