0
Please help me in js store manager project
JavaScript project
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
+ 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);
}
+ 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)
}
+ 3
What help?
+ 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
+ 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);
}
0
What help Satyam Karn ....please justify your doubt....
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
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);
}
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
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
0
For(var I=0:; I<=prices.length-1; I++)
{
Prices[i]= prices[i] + increase;
}
Console.log(prices);
0
console.log(prices.map(e => e + increase));
0
for (var i = 0; i < prices.length; i++) {
prices[i] = prices[i] + increase;
}
console.log(prices);
}
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
- 1
I was lerning js and sen a question in project store manager
- 1
function main() {
var increase = parseInt(readLine(), 10);
var prices = [98.99, 15.2, 20, 1026];
//your code goes here
}
help