How to increment all the values in an array with Node.js

1 Answer

0 votes
let arr = [1, 2, 3, 4, 5, 6, 7, 8];

arr = arr.map(element => element + 3);

console.log(arr);

  
  
  
  
/*
run:
  
[4, 5, 6, 7, 8, 9, 10, 11]

*/

 



answered May 6, 2022 by avibootz

Related questions

1 answer 133 views
1 answer 120 views
1 answer 110 views
110 views asked May 3, 2022 by avibootz
1 answer 138 views
1 answer 192 views
1 answer 143 views
...