Skip to content

Instantly share code, notes, and snippets.

@RaynZayd
Last active February 12, 2023 23:42
Show Gist options
  • Save RaynZayd/a97dc7b895832afdce6357ee76bc88d0 to your computer and use it in GitHub Desktop.
Save RaynZayd/a97dc7b895832afdce6357ee76bc88d0 to your computer and use it in GitHub Desktop.
A program that will register runners for a race and give them instructions on the race day
/*A program that will register runners for a race and give them instructions on the race day.
A timeline of the registration:
How the registration works...
There are adult runners 18+ and youth runners -18 years of age.
They can register early or late.
Runners are assigned a race number and start time based on their age and registration.
Race number:
Early adults receive a race number at or above 1000.
All others receive a number below 1000.
Start time:
Adult registrants run at 9:30 am or 11:00 am.
Early adults run at 9:30 am.
Late adults run at 11:00 am.
Youth registrants run at 12:30 pm regardless of registration.
But, runners exactly 18! Will have to see the desk.*/
let raceNumber = Math.floor(Math.random() * 1000);
var early = true;//Play around with this to see different results
var late = false;//Can set early or late variables either one of boolean values
var runnerRegistered = late;
var runnerAge = 22;
if(runnerAge > 18 && runnerRegistered === early){
raceNumber += 1000;
}
if(runnerAge > 18 && runnerRegistered === early){
console.log(`Race will begin at 9:30 am and your race number is ${raceNumber}`);
}else if(runnerAge > 18 && runnerRegistered === late){
console.log(`Race will begin at 11:00am and your race number is ${raceNumber}`);
}else if(runnerAge < 18){
console.log(`You\'ll race at 12:30am ${raceNumber}`);
}else{
console.log('See the registration desk');
}
@Blackwidow8legs
Copy link

kindly check my updated code , on my profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment