- script.js
JavaScript
var score = 0;
var total = 0;
while (score > -1) {
score = muffin.getScore();
total += score;
}
console.log(total);
Result
Goalscompleted
Let’s add a loop, record hits in it and log them in the console.
- Add variable
victoryPoints
, which will store100
, the number of points needed to win. - Replace the loop stop condition to get the required number of points
total < victoryPoints
. - In the loop, log in the console the result of the shot from the variable
score
.
Comments