0

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){ 
  
}
j08691
  • 204,283
  • 31
  • 260
  • 272
LyonKing
  • 11
  • 1

1 Answers1

0

is this what you need?

const increaseByTwo = [1, 2, 3, 4, 5];
var newArr = [];
increaseByTwo.forEach(e=>newArr.push(e+2))

console.log(newArr)
Sarout
  • 821
  • 4
  • 25