Skip to content

Instantly share code, notes, and snippets.

@LinZap
Created June 8, 2019 20:41
Show Gist options
  • Save LinZap/8b87fb5188b2966cadb072f500db2c44 to your computer and use it in GitHub Desktop.
Save LinZap/8b87fb5188b2966cadb072f500db2c44 to your computer and use it in GitHub Desktop.
Node.js -HK3
function map(arr,fun){
for(let i=0;i<arr.length;i++)
arr[i] = fun(arr[i])
return arr;
}
const arr = [1,2,3,4,5]
const new_arr = map(arr,function(n){
return n*100
});
console.log(new_arr);
[ 100, 200, 300, 400, 500 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment