Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 23, 2020 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/8dd1cb546469ad6ac374988fd6de4b6a to your computer and use it in GitHub Desktop.
Save codecademydev/8dd1cb546469ad6ac374988fd6de4b6a to your computer and use it in GitHub Desktop.
Codecademy export
// Race number generation (rN)
let raceNumber = Math.floor(Math.random() * 1000);
// Registration early or late (rE)
const registeredEarly = true;
// Age of runner (rA)
const runnersAge = 22;
// Control and verification of rE & rA = rN
if (registeredEarly && runnersAge > 18) {
raceNumber += 1000;
}
// Assignment of rN and time slot
// Early Adults
if (runnersAge > 18 && registeredEarly) {
console.log(`Your race will begin early, at 09:30. Your assigned race number is ${raceNumber}. Good luck!`);
} // Late Adults
else if (runnersAge > 18 && !registeredEarly) {
console.log(`Your race will begin late, at 11:00. Your assigned race number is ${raceNumber}. Good luck!`);
} // Youth race
else if (runnersAge < 18) {
console.log(`Your race will begin at 12:30. Your assigned race race number is ${raceNumber}.`);
}
else { // Failure of assignment
console.log('Please report to the registration desk for assignment of race number and time slot.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment