JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Refactor Using a Loop

what part am i missing?

for (var i = 0; i <= 22; i =+ 2){ console.log(i) }

script.js
for (var i =0; i <= 22; i =+ 2) {
    console.log(i);
}
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

1 Answer

Elijah Quesada
Elijah Quesada
Front End Web Development Techdegree Graduate 30,767 Points

A Couple issues with your for loop

  1. Your current loop will start off at 0 and not 2.
  2. i =+ 2 should be i += 2
  3. Your loop will stop at 22 not 24.
for (var i = 2; i <= 24; i += 2) {
    console.log(i);
}