Advertisement
makispaiktis

Codecademy - 10th Exercise (Race Day)

Oct 1st, 2019 (edited)
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let raceNumber = Math.floor(Math.random() * 1000);
  2. // Initializing the 2 variables of the problem
  3. let earlyRegistered = true;
  4. let runnerAge = 20;
  5.  
  6. // Conditionals, changing the raceNumber variable
  7. if(runnerAge > 18 && earlyRegistered === true){
  8.   raceNumber += 1000;
  9. }
  10.  
  11. // Conditionals
  12. if(runnerAge > 18 && earlyRegistered === true){
  13.   console.log(`Participant No ${raceNumber} will run at 9:30 am.`);
  14. }
  15.  
  16. else if(runnerAge > 18 && earlyRegistered === false){
  17.     console.log("Late adults will run at 11:00 am.")
  18. }
  19.  
  20. else if(runnerAge < 18){
  21.   console.log(`Participant No ${runnerAge} will run at 12:30 am.`);
  22. }
  23.  
  24. // Else-case, when runnerAge = 18 EXACTLY
  25. else{
  26.   console.log("You are exactly 18 years old, so you have to check the registration desk.");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement