- 3
store manager porject in javascript
Hi all I have written my code (I have tried) and now I am stuck as it only changes the first value. mu output is: 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] +=increase; console.log(prices); } } I should be showing: [ 107.99, 24.2, 29, 1035 ] but i have :[ 107.99, 15.2, 20, 1026 ] please may I ask for some help and where I have gone wrong please.
5 Respuestas
+ 2
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
}
console.log(prices)
}
+ 1
You should repeat the material covered, since you managed to make 3 mistakes in one cycle ☺️
👇 👇
for (var i=0; i>prices.length; i++); {
pricesil+=increase;
console.log(prices); 🤔
}
0
function main(){
var increase = parseInt(readLine(), 10);
var prices = [98.99, 15.2, 20, 1026];
//your code goes here
var newprice = [];
for (const i in prices) {
newprice.push(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
var pl = prices.length;
for(i=0; i<pl;i++){
prices[i]+=increase
}
console.log(prices)
}
- 1
The error is in the code, on one of the lines, with one of the things.