The Medal
Now the medals. An archer's score is their points plus a bonus for every bullseye, an arrow worth 10 points. Each bullseye brings bullseyeBonus extra points: that's a new constant at the top of the program. The score decides the medal: gold from 45 points, silver from 35 and bronze from 25. With a lower score, there's no medal.
Add the bullseyes with their bonus, the score and the medal below what the program already prints. For Kira, the whole output is:
Archer: Kira
Hits: 5 of 6 arrows
Points: 40
Bullseyes: 2 (bonus 10)
Score: 50
Medal: goldKira's two bullseyes bring her 10 extra points, so her score is 50, and that's a gold medal.
The exercise tries other arrows too, so make sure that the program awards every medal correctly, also right at the limits: a score of exactly 35 is silver. With [9, 9, 8, 7], there's no bullseye, the score is 33, and the medal is bronze. With [10, 0, 0, 8], the score is 23, and the program prints Medal: none.
A tip: when the medal is in a variable created without a value and set in the branches of an if, TypeScript checks that no branch forgets it, as you saw in the Basic Types lesson.
Instructions
Print the number of bullseyes with their bonus, and the score.
Print the medal. When the score isn't enough for any, print Medal: none.
Start programming for free
2/3