+ 10

I need help with the store manager question

function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here let newPrices = []; for (let i = 0; i < prices.length; i ++) { var n = prices[i] + increase; newPrices.push(n); console.log(newPrices); }; };

14th Dec 2020, 5:45 PM
Augustine Ansah Owusu
Augustine Ansah Owusu - avatar
20 Respostas
+ 18
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var incPrice = prices.map(cur => cur + increase); console.log(incPrice); }
12th Jan 2021, 3:08 PM
Ayoola Paul oluwamayowa
Ayoola Paul oluwamayowa - avatar
+ 8
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:06 PM
Taral Patel
Taral Patel - avatar
+ 4
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here i=0; for(;i<prices.length;) { prices[i] += increase; i++; } console.log(prices); } There you go.
6th Oct 2021, 2:11 PM
Bartosz Buczkowski
Bartosz Buczkowski - avatar
+ 4
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here prices[0] = prices[0] + increase ; prices[1] = prices[1] + increase ; prices[2] = prices[2] + increase ; prices[3] = prices[3] + increase ; console.log (prices); } basic but good
10th Dec 2021, 3:27 PM
Vu Ba Luc
Vu Ba Luc - avatar
+ 1
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here const result=[]; for (let i = 0; i < prices.length; i += 1) { result.push(prices[i] += increase) } console.log(result); }
9th Jan 2022, 11:29 PM
Alexander Lutsyk
Alexander Lutsyk - avatar
+ 1
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var newPrices = prices.map(x => x + increase) console.log(newPrices) }
25th Jan 2022, 1:50 AM
Hector M. Gomez
+ 1
//Sololearn expected output: [ 107.99, 24.2, 29, 1035 ] function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here function newPrizes(x) { return x + increase; } console.log(prices.map(newPrizes)); }
6th Feb 2022, 8:50 PM
Mylisa_beth
Mylisa_beth - avatar
+ 1
For my code 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++) { var result = prices[i] + increase prices[i] = result } console.log(prices) }
8th Nov 2022, 1:52 AM
GameWatch21
GameWatch21 - avatar
+ 1
We should explain the code if somebody is stuck rather than just sharing the answer. Users will need to understand concepts to begin a development career. This is an older post but leaving this here for people looking for the answer. I paste the code into Notepad++ files and comment each line to make sure I understand it. Here is what I have in my notes. function main() { // Initializes the MAIN function var increase = parseInt(readLine(), 10); // Creates a variable called INCREASE and assigns user input as the value var prices = [98.99, 15.2, 20, 1026]; // Creates an array called PRICES and assigns 4 values for (let i = 0; i < prices.length; i++) { // A for loop that runs as long as the value of i is less than the length of the PRICES array prices[i]+=increase; // Adds int INCREASE value to each index of the PRICE array } console.log(prices); // Outputs the new PRICE value for each price assigned to the PRICES variable
6th Oct 2023, 3:22 PM
Ken S
Ken S - avatar
0
Check this out : function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; prices.forEach((item, index, arr) => { arr[index] = item + increase }) console.log(prices) }
16th Aug 2021, 2:53 PM
hamid fattahi
hamid fattahi - avatar
0
You can use push method in array, check this out : function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here let result = []; for (let i = 0; i < prices.length; i++) { result.push(prices[i] + increase); } console.log (result); }
4th Dec 2021, 8:55 AM
Rikhi Sobari
Rikhi Sobari - avatar
0
Here is my solution : function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var i = prices.length - 1; while(i >= 0){ prices[i] = prices[i] + increase; i--; } console.log(prices); }
21st Feb 2022, 2:27 PM
Louis Tychon
Louis Tychon - avatar
0
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var newPrices = []; for( i = 0; i < prices.length; i++){ newPrices.push(prices[i] + increase); } console.log(newPrices) }
3rd Apr 2022, 9:12 AM
Rajkumar Shil
Rajkumar Shil - avatar
0
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]=prices[i]+increase } console.log(prices); }
20th Jul 2022, 9:56 PM
Abdulhamit TURAN
Abdulhamit TURAN - avatar
0
If you want to be even more specific, you can make sure that your code still works if you decide to add more arguments into the prices array. function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; var x = prices.length for (i=0; i<x; i++){ prices[i] = increase + prices[i] } console.log(prices)
25th Aug 2022, 12:54 PM
Andy Vande Voorde
0
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) }
17th Sep 2022, 6:08 PM
Kanisak Shakya
Kanisak Shakya - avatar
0
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here var newPrices=prices.map(myFunction) function myFunction(num) { return num+increase; } console.log(newPrices); }
5th Oct 2022, 3:14 PM
Gƶzde GĆ¼rler
0
function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here i=0; for(;i<prices.length;) { prices[i] += increase; i++; } console.log(prices); }
5th Oct 2022, 3:25 PM
Marcel KrƤttli
0
I want to Try 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-1; i++){ var prevPrice =prices[i]; var newPrice = prevPrice + increase ; prices[i]= newPrice; } //var incPrice = prices.map(cur => cur + increase); //console.log(incPrice); console.log(prices); }
22nd Sep 2023, 5:49 AM
John Paul Arellano
John Paul Arellano - avatar
- 8
Check those links. Next time try to use the search bar, most of the time your questions has already been asked, and so answered. https://www.sololearn.com/Discuss/2621003/?ref=app https://www.sololearn.com/Discuss/2612434/?ref=app
14th Dec 2020, 8:35 PM
Gabriele Gatti
Gabriele Gatti - avatar