0

How yo add an array

If I have an array of predetermined numbers I.e. Var prices = [10, 20, 30, 40]; And the user inputs me a value I.e. Var increase = parseInt ( input()); How can I program JavaScript to add the user increase to my original array and output the new array? I.e. Input = 2 Output [12, 22, 32, 42]

11th Jun 2021, 1:54 AM
Daniel Lopez
4 Answers
+ 1
var prices_inc = prices.map(v => v+increase);
11th Jun 2021, 1:58 AM
visph
visph - avatar
+ 1
Thanks!
11th Jun 2021, 2:14 AM
Daniel Lopez
0
It worked!! Could tou explain to me what the .map and de V=> do?
11th Jun 2021, 2:02 AM
Daniel Lopez