Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // INPUT
- let numbers = [1, 2, 3, 4];
- let results = [];
- // MULTIPLY EACH ARRAY ITEM BY 2
- function multiplyBy2(currentValue, index, arr) {
- return currentValue*2;
- }
- results = numbers.map(multiplyBy2);
- // OUTPUT
- // [2, 4, 6, 8]
Add Comment
Please, Sign In to add comment