- 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
score
in the console, increase the value oftotal
toscore
using the operator+=
. - After the loop, log the value of the variable
total
in the console.
Comments