Skip to content

Instantly share code, notes, and snippets.

@mokshchadha
Created October 26, 2023 05:13
Show Gist options
  • Save mokshchadha/fe7f3a415f49dace6e8830a0dd202001 to your computer and use it in GitHub Desktop.
Save mokshchadha/fe7f3a415f49dace6e8830a0dd202001 to your computer and use it in GitHub Desktop.
create map filter from scratch
function mapArray(arr,cb){
let res = [];
for(const e of arr){
res.push(cb(e));
}
return res;
}
function filterArray(arr, cb){
let res = [];
for(const e of arr){
const isAllowed = cb(e);
if(isAllowed){
res.push(e)
}
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment