0

I am working on a store manager program that stores values in an array and can be added to value. I get price object not defined

The array is called prices and the input value from the users is called increase. My code looks like this function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here for (i = 0; i< prices.length; i++) { prices[i] += increase; } return prices; } console.log(prices);

19th Aug 2021, 1:15 PM
Adigwe Leo
Adigwe Leo - avatar
3 Réponses
+ 1
Maybe you are mixing up the code from code coach that runs in nodejs environment with the one in browser. There is no readLine method that js supports in browser . Also you need to call the main function.
19th Aug 2021, 1:21 PM
Abhay
Abhay - avatar
+ 1
Abhay I put the console.log(prices) inside the main function and the error I'm getting is no output
19th Aug 2021, 1:29 PM
Adigwe Leo
Adigwe Leo - avatar
+ 1
Adigwe Leo function main() { var increase = parseInt(prompt()); var prices = [98.99, 15.2, 20, 1026]; //your code goes here for (i = 0; i< prices.length; i++) { prices[i] += increase; } return prices; } console.log(main());
19th Aug 2021, 1:33 PM
Abhay
Abhay - avatar