- script.js
JavaScript
var score = 0;
var total = 0;
var victoryPoints = 100;
while (total < victoryPoints) {
score = muffin.getScore();
total += score;
console.log('Result of the shot: ' + score);
}
console.log(total);
Result
Goalscompleted
Add a reaction to misses.
- Before the loop add a variable for misses
misses
with a zero value. - In the next line after
muffin.getScore()
, add a miss checkif (score < 0) { }
. - If this condition is met, add
console.log('You missed!');
- and increasing the
misses
variable by one. - Move the increase in the total number of points to
else
and log the shot result in the console.
Comments