- script.js
JavaScript
var score = muffin.getScore();
while (score > -1) {
console.log(score);
score = muffin.getScore();
}
Result
Goalscompleted
- On the next line after the variable
score, declare a variabletotal, which equals0. - Inside the loop, instead of logging the variable
scorein the console, increase the value oftotaltoscoreusing the operator+=. - After the loop, log the value of the variable
totalin the console.
Comments