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

+2

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

12 Answers

New Answer

+12

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

+5

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

+2

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.

+1

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

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

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

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

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

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

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

-7

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