0
Help me with the code-project in javascript-intermediate
I have been stuck in the problem Store Manager function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here for(let i =0;i< prices.length;i++){ prices[i]+=increase; console.log(prices[i]); } } The topic said to add functionality to increase the prices by the given amount. Your Output 107.99 24.2 29 1035 Expected Output [ 107.99, 24.2, 29, 1035 ]. How to display like the `Expected Output`. Please help me. Thank you
2 Answers
+ 1
Ah the solution is to take the console.log out of the loop and replace`[i]`
+ 1
// It is a bit advance but here you go.
function main() {
var increase = parseInt(readLine(), 10);
let prices = [98.99, 15.2, 20, 1026];
//your code goes here
return prices.map(num => num + givenValue)
}
console.log(main())
//working with arrays become very easy if you know the some of the major array methods.
// Here is a link to a YouTube Video, which is a must watch to learn how to work with arrays like pro,
// https://www.youtube.com/watch?v=R8rmfD9Y5-c&ab_channel=WebDevSimplified