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 125 views
1 answer 109 views
1 answer 103 views
103 views asked May 3, 2022 by avibootz
1 answer 128 views
1 answer 172 views
1 answer 131 views
...