Hey, Student! Your solution looks good. You've almost got it. One of the frustrating things about writing software is that you can be 99% there... and one bug breaks the whole thing!
Here's a tip that might help you here and with similar issues in the future.
When debugging, it's useful to experiment by isolating variables and testing with simpler scenarios. Try replacing alert(prizes[btnNum]);
with alert(prizes[0]);
. This isn't the functionality we want in the end, but simplifying the logic will tell us if there's a problem with the btnNum
variable or with the alert
array itself.
You should see that with prizes[0]
the alert box displays A Unicorn!
just as expected! This is a big clue. It means the problem must be with btnNum
.