Created
March 31, 2020 11:32
-
-
Save ilanl/5e537116482b50823e18b0f7989bba3e to your computer and use it in GitHub Desktop.
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
function map(arr, mapCallback) { | |
if (!Array.isArray(arr) || !arr.length || typeof mapCallback !== 'function') { | |
return []; | |
} else { | |
let result = []; | |
for (let i = 0, len = arr.length; i < len; i++) { | |
result.push(mapCallback(arr[i], i, arr)); | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment