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 214 views
1 answer 195 views
1 answer 180 views
180 views asked May 3, 2022 by avibootz
1 answer 221 views
1 answer 269 views
1 answer 237 views
...