Skip to content

Instantly share code, notes, and snippets.

@tonis2
Last active October 15, 2015 13:54
Show Gist options
  • Save tonis2/0b222d4308457d611745 to your computer and use it in GitHub Desktop.
Save tonis2/0b222d4308457d611745 to your computer and use it in GitHub Desktop.
es6 Map function
let numbers = [6, 3, 9];
function map(data,func){
let numbers = [];
for (let i in data){
let as = func(data[i]);
numbers.push(as);
}
return numbers;
}
function divide(random){
return random *3;
}
let answer = numbers.map(divide);
console.log(answer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment