Interactive online courses HTML Academy
2026-03-09 12:55 Diff
  • script.js

JavaScript

var sum = 0; for (var i = 1; i <= 10; i++) { console.log('i: ' + i); // Add a check here console.log('sum: ' + sum); }

Thanks! We’ll fix everything at once!

Result

  1. Inside the loop, add a check to make sure that the counter is even (i % 2 === 0).
  2. If the check is executed, increase the variable sum by 2.
  3. Inside the condition, after increasing the sum, log the 'even number' string in the console.
  4. After the check is complete, add the else branch and increase the sum inside it by 1.
  5. Inside the else, after increasing the sum, log the 'odd number' line in the console.