Skip to content

Instantly share code, notes, and snippets.

@ilanl
Created March 31, 2020 11:32
Show Gist options
  • Save ilanl/5e537116482b50823e18b0f7989bba3e to your computer and use it in GitHub Desktop.
Save ilanl/5e537116482b50823e18b0f7989bba3e to your computer and use it in GitHub Desktop.
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