0

Please help me in js store manager project

JavaScript project

23rd Dec 2020, 4:31 AM
Satyam Karn
Satyam Karn - avatar
17 odpowiedzi
+ 6
You need to initiative an empty array to store the new prices, then loop over the prices array, then add each old price with increase variable and lastly append the sum to the new price array. e.g 1. newPrice =[]; //empty array 2. Use the forloop to get item index in array price array 3. newPrice.push(price[index] + increase); // append the new price to array 4.console.log(newPrice) // print out the array
4th Jan 2021, 7:53 AM
Zyambo
Zyambo - avatar
+ 7
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-1; i++){ prices[i]= prices[i] + increase; } console.log(prices); }
7th Feb 2021, 5:09 PM
Anikesh Kulal
Anikesh Kulal - avatar
+ 4
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here for (i=0; i<4; i++){ prices[i] = increase + prices[i]; } console.log(prices) }
11th Jan 2021, 5:05 PM
Taral Patel
Taral Patel - avatar
+ 3
What help?
23rd Dec 2020, 4:34 AM
A͢J
A͢J - avatar
+ 2
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here function newPrices (increase){ prices[0]= prices[0]+ increase.toNumber prices[1]= prices[1]+ increase.toNumber prices[2]= prices[2]+ increase.toNumber prices[3]= prices[3]+ increase.toNumber return prices[0][1][2][3] } console.log(prices) } What do I do next? I'm only getting one of the test cases
3rd Jun 2021, 7:51 AM
Nmelichukwu Ubosi
Nmelichukwu Ubosi - avatar
+ 1
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; for(var i=0; i<prices.length; i++) prices[i] += increase; console.log(prices); }
1st Mar 2021, 6:28 AM
Mohamed BOUANANE
Mohamed BOUANANE - avatar
0
What help Satyam Karn ....please justify your doubt....
23rd Dec 2020, 5:21 AM
Abhinav Raj
Abhinav Raj - avatar
0
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. This is my question
23rd Dec 2020, 6:12 AM
Satyam Karn
Satyam Karn - avatar
0
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var newPrice = new Array(); for (var i=0;i< prices.length ; i++){ newPrice[i] = prices[i]+increase; } console.log(newPrice); }
11th Aug 2021, 7:40 PM
Ranu Pathiranage
Ranu Pathiranage - 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-1;i++){ prices[i]=prices[i]+increase; } console.log(prices); } its working
17th Aug 2021, 12:17 PM
Swadhin Kumar
Swadhin Kumar - 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-1;i++){ prices[i]=prices[i]+increase; } console.log(prices); } its working
17th Aug 2021, 12:17 PM
Swadhin Kumar
Swadhin Kumar - avatar
0
For(var I=0:; I<=prices.length-1; I++) { Prices[i]= prices[i] + increase; } Console.log(prices);
2nd Oct 2021, 10:33 AM
Pritesh Rupapara
0
console.log(prices.map(e => e + increase));
2nd Oct 2021, 4:49 PM
Kevin Alexander Alvarez Echeverri
Kevin Alexander Alvarez Echeverri - avatar
0
for (var i = 0; i < prices.length; i++) { prices[i] = prices[i] + increase; } console.log(prices); }
9th Nov 2021, 4:27 PM
StelKros
StelKros - avatar
0
So to solve this problem, 1.create an empty array eg newArray = [], make sure it is outside the loop 2. Next you loop through the prices array using for loop and the increament each item in the prices array 3. next push the new or increamented index to the new array ir newPrices.push(price[i] + increament) 4, console log the finanl resut
24th Sep 2022, 9:05 PM
Moses Nyikwagh
- 1
I was lerning js and sen a question in project store manager
23rd Dec 2020, 6:09 AM
Satyam Karn
Satyam Karn - avatar
- 1
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here } help
1st Jan 2021, 12:32 PM
Ilya Ermishin
Ilya Ermishin - avatar