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 ();

8th Jan 2021, 1:44 PM
Sunil Mahato
Sunil Mahato - avatar
1 Respuesta
0
Call to map was incorrect, try like this ... let finalPrice = prices.map( value => value + increase ); https://www.w3schools.com/jsref/jsref_map.asp
8th Jan 2021, 2:33 PM
Ipang