The Final
Kira has made it to the final, and her rival there is Bruno. His name and arrows are in two new constants, rival and rivalArrows. Print Bruno's scoreboard below Kira's, with the same six lines, and then announce the winner, the archer with the higher score. The output ends like this:
Medal: gold
Archer: Bruno
Hits: 4 of 5 arrows
Points: 36
Bullseyes: 2 (bonus 10)
Score: 46
Medal: gold
Winner: KiraWhen both archers have the same score, the program prints It's a tie! instead of the winner.
A tip: you don't want to write the same lines twice. Put everything that prints an archer's scoreboard into a function that takes the name and the arrows. It can also return the score, which you need for the winner. TypeScript then checks every call: that it passes a text and an array of numbers, in this order.
That's the whole project. With three lessons of TypeScript behind you, you've written a program whose data and functions all have types, so TypeScript checked every calculation and every call before the program ran. In the next lesson, Object Types, you'll learn to describe objects. An archer could then be one object with a name and arrows, and TypeScript would check it too.
Instructions
Print the rival's scoreboard below Kira's.
Print the winner, or It's a tie! when the scores are the same.
Start programming for free
3/3