
Race Day
For this project, I wrote a progam that registers runners for a race and provides them with instructions on race day. This project showcases my understanding of control flows, using if else, else if, and switch.
1. I started by generating a random number and setting that number equal to the variable "raceNumber".
2. Next, (line 8), I checked to see if a runner is over the age of 18 and registered early. If so, then I logged to the console (leveraging string interpolation - their race number) will race at 9:30am. These are the instructions racers that registered early and are over the age of 18 will receive.
Since I used "Math.random" to generate a random number, every time I run the program and log to the console, the number is different each time.
3. Next, (line 10), I checked to see if a runner is over the age of 18 and didn't register early for the race by using an "else if" statement. If anyone meets this criteria, then "${raceNumber} will race at 11:00am." will display.
Additionally, (line 12), I'm catching all other criteria by leveraging an "else" statement for those under the age of 18. If any racers meet this criteria, then "${raceNumber} will race at 12:30pm." will display.
4. I made sure that my program works correctly (i.e., the correct times are being logged to the console) by changing the values in the following variables:
-runnerAge
-earlyRegistration
5. Lastly, I accounted for those OVER and UNDER 18 but what about those that are EXACTLY 18? To make sure I included those racers, I added an "else" statement that will log "${raceNumber see the registration desk".






Post a comment