Task: Use a for loop to iterate through the array and increase each number by two.
const increaseByTwo = [1, 2, 3, 4, 5];
What is wrong with my code here?
for (let i = 0; i < increaseByTwo.length; i+=2){
}
Task: Use a for loop to iterate through the array and increase each number by two.
const increaseByTwo = [1, 2, 3, 4, 5];
What is wrong with my code here?
for (let i = 0; i < increaseByTwo.length; i+=2){
}
is this what you need?
const increaseByTwo = [1, 2, 3, 4, 5];
var newArr = [];
increaseByTwo.forEach(e=>newArr.push(e+2))
console.log(newArr)