JavaScript
x
11
11
1
function main() {
2
var increase = parseInt(readLine(), 10);
3
var prices = [98.99, 15.2, 20, 1026];
4
//your code goes here
5
for(var i=0;i<prices.length;i++)
6
{
7
var b=prices[i]+increase;
8
console.log(+b);
9
}
10
}
11
Here the output is displayed in seperate elements but I want all the elements in a single array.
Advertisement
Answer
You should just create array and push into it:
JavaScript
1
13
13
1
function main() {
2
let result = [];
3
var increase = parseInt(readLine(), 10);
4
var prices = [98.99, 15.2, 20, 1026];
5
//your code goes here
6
for(var i=0;i<prices.length;i++)
7
{
8
var b=prices[i]+increase;
9
result.push(b);
10
}
11
12
return result;
13
}