Created
January 11, 2018 21:33
-
-
Save javanigus/cf003f096375d67e4a9e10e76f471ad5 to your computer and use it in GitHub Desktop.
Example JavaScript 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
// INPUT | |
let numbers = [1, 2, 3, 4]; | |
let results = []; | |
// MULTIPLY EACH ARRAY ITEM BY 2 | |
results = numbers.map(function (currentValue, index, arr) { | |
return currentValue*2; | |
}); | |
// OUTPUT | |
// [2, 4, 6, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment