0

Hi guys can you help to figure this out

You are working on a Store Manager program, which stores the prices in an array. You need to add functionality to increase the prices by the given amount. The increase variable is taken from user input. You need to increase all the prices in the given array by that amount and output to the console the resulting array.

18th Nov 2021, 12:17 AM
OUABI ABDESSAMAD
OUABI ABDESSAMAD - avatar
7 Answers
+ 5
//try this for(var i=0;i<prices.length; i++ ){ prices[i] = increase+prices[i] } console.log(prices) }
18th Nov 2021, 7:20 AM
Simba
Simba - avatar
+ 1
Take user input which will be increase in all prices. Use for loop to do that.
18th Nov 2021, 12:24 AM
A͢J
A͢J - avatar
+ 1
So where is your attempts?
18th Nov 2021, 12:27 AM
A͢J
A͢J - avatar
+ 1
//try this function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here for(var i=0; i<prices.length; i++){ prices[i] = prices[i] + increase; } console.log(prices); }
1st Aug 2022, 1:19 PM
shadman Ahmadi
shadman Ahmadi - avatar
0
I tried but couldn't find the answer
18th Nov 2021, 12:25 AM
OUABI ABDESSAMAD
OUABI ABDESSAMAD - avatar
0
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here for(var i=0;i<prices.length; i++ ){ console.log(increase+prices[i]) } }
18th Nov 2021, 12:28 AM
OUABI ABDESSAMAD
OUABI ABDESSAMAD - avatar
0
OUABI ABDESSAMAD console.log bydefault add new line so that would be right way to increase amount. So you can do 1 thing: increase amount then assign to same array data like prices[i] = prices[i] + amount; then finally print prices
18th Nov 2021, 7:26 AM
A͢J
A͢J - avatar