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.
7 Answers
+ 5
//try this
for(var i=0;i<prices.length; i++ ){
prices[i] = increase+prices[i]
}
console.log(prices)
}
+ 1
Take user input which will be increase in all prices.
Use for loop to do that.
+ 1
So where is your attempts?
+ 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);
}
0
I tried but couldn't find the answer
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])
}
}
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