- 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 thati
is greater than5
. - If the condition is triggered, increase
sum
by2
. - Add the
else
branch and transfer into it the stringsum += i;
.
Comments