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);
3 Antworten
+ 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.
+ 1
Abhay I put the console.log(prices) inside the main function and the error I'm getting is no output
+ 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());