I need help with the store manager question | Sololearn: Learn to code for FREE!

-1

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); }; };

12/14/2020 5:45:34 PM

Augustine Ansah Owusu

8 Answers

New Answer

+13

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); }

+3

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) }

+1

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.

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) }

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); }

0

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

0

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); }

-4

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