+ 1
I DON'T KNOW HOW TO DO IT
i need that my out put come in a certain way, this is my code : function main() { var increase = parseInt(("1"), 10); var prices = [98.99, 15.2, 20, 1026]; //tu cĂłdigo va aquĂ //let arr = [1, 2, 3]; for (let k = 0; k < prices .length; k++) { console.log(prices[k] + increase ); } } main() the problem is that the output comes like this: 99.99 16.2 21 1027 but i need that the out put come like this: [99.99, 16.2, 21, 1027] i don't know how to do it exactly , if someone know how to do it, it would be awesome
2 Answers
+ 2
//Here is the js code.
function main() {
var increase = parseInt(("1"), 10);
var prices = [98.99, 15.2, 20, 1026];
//empty array where we store the new values
let arr = [];
//tu cĂłdigo va aquĂ
//let arr = [1, 2, 3];
for (let k = 0; k < prices .length; k++) {
//console.log(prices[k] + increase );
//storing the new values.
arr.push(prices[k]+increase);
}
//writing the array
console.log(arr)
document.write(arr)
}
main()
+ 1
đ Alex TuÈinean đ thanks man Jesus Christ bless you, it worked fine, finely . I was even looking on the internet but didn't find anything, thanks again đ