Guest User

Untitled

a guest
Jan 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. // INPUT
  2. let numbers = [1, 2, 3, 4];
  3. let results = [];
  4.  
  5. // MULTIPLY EACH ARRAY ITEM BY 2
  6. function multiplyBy2(currentValue, index, arr) {
  7. return currentValue*2;
  8. }
  9.  
  10. results = numbers.map(multiplyBy2);
  11.  
  12. // OUTPUT
  13. // [2, 4, 6, 8]
Add Comment
Please, Sign In to add comment