- script.js
JavaScript
var sum = 0;
for (var i = 1; i <= 10; i++) {
// Add a condition here
sum += i;
console.log('i: ' + i);
console.log('sum: ' + sum);
}
Result
Goalscompleted
- Inside the loop, before increasing
sum, add a check to make sure thatiis greater than5. - If the condition is triggered, increase
sumby2. - Add the
elsebranch and transfer into it the stringsum += i;.
Comments