- script.js
JavaScript
Result
Goalscompleted
- At the beginning of the code, create variable
sum, which equals0. - Below, after the variable, create a loop
for, which increases the value of the counterifrom1to10inclusively. - Inside the loop, at each iteration, increase the sum by the counter value
sum += i;. - In the body of the loop, after increasing
sum, log'i: ' + iin the console. - Then log
'sum: ' + sumin the console.
Comments