0
Adding number to each element in an array
First of all thanks for your help... I've tried to add numeric value to each element in the array. But the output I got was NaN. I tried using map() method to add numeric value. I also used parseInt() to get number.. But result was same. I've used the following code: const main = () => { let increase = parseInt(readLine(),10); let prices = [98.99, 15.2, 20, 1026]; //your code goes here let finalPrice = prices.map(result=(value)=> { return value+increase; }); console.log(finalPrice); } main ();
1 Resposta
0
Call to map was incorrect, try like this ...
let finalPrice = prices.map( value => value + increase );
https://www.w3schools.com/jsref/jsref_map.asp