Last active
October 15, 2015 13:54
-
-
Save tonis2/0b222d4308457d611745 to your computer and use it in GitHub Desktop.
es6 Map function
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
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