Code review appreciated for Race Day project - JS

Hello,

I have just completed the JavaScript race day project. Any feedback on my code would be greatly appreciated!

let raceNumber = Math.floor(Math.random() * 1000);
let earlyRaceNumber = Math.floor(Math.random() * 1000 + 1000);
let runnerRegEarly = "";
let runnerAge = 18;
if (runnerAge > 18 && runnerRegEarly) {
  console.log(
    `Your race will begin at 09:30. Your race number is ${earlyRaceNumber}.`
  );
} else if (runnerAge > 18 && !runnerRegEarly) {
  console.log(
    `Your race will begin at 11:00. Your race number is ${raceNumber}.`
  );
} else if (runnerAge < 18) {
  console.log(
    `Your race will begin at 12:30pm. Your race number is ${raceNumber}`
  );
} else {
  console.log("Please see the registration desk.");
}

Hello, I cant give you feedback as such as im only just learning myself. This looks different to mine and probably better from my understanding. here’s mine, please feel free to criticize my code as I’m not even sure if its correct haha
im not quite sure how you managed to post your code so I’ll copy and paste and also send the gist link. thankyou :slight_smile:

let raceNumber = Math.floor(Math.random() * 1000);
const registeredEarly = false;
const registeredLate = true;
const age = 19;
if (age > 18 && registeredEarly) {
console.log('The race will begin for the early over 18s at 9:30am and your race number is ’ + (1000 + raceNumber));
}
else if (age > 18 && registeredLate) {
console.log('The race will begin for the late over 18s at 11:00am and your race number is ’ + (raceNumber));
}
else if (age < 18) {
console.log('The race will begin for the under 18s at 12:30pm and your race number is ’ + (raceNumber));
}
else if (age === 18 || registeredEarly)
console.log(‘For peaple who are 18, please refer to the registration desk.’)

Please review my code and any feedback appreciated!

Hi, I’m a beginner too, it seems your code is not following the objective as you are introducing a condition of early registration for runners of exactly 18 years old, which is unnecessary, and you are adding 1000 on their number when the exercise asked you to do this only for people above 18 years old, to whom you are not adding 1000 - to their number…

Hello I am a beginner here, I’ll still give you my comments: you declare two different random numbers, one for raceNumber and one for earlyRaceNumber, when this extra variable doesn’t seem necessary at all in this program. You posted this exercise a long time ago so you must have much more coding experience by now and will find my comment useless ! Cheers

Hello, would anyone be as kind as to review my code please ?

The first part is working fine but in the comments in the end I added another coding attempt to this exercise but I am having this message “syntax error : unexpected token”

Could anyone please explain me what is wrong in my ternary operation in the second version ? I am a total beginner thank you in advance.

let raceNumber = Math.floor(Math.random() * 1000);
let earlyRegistration = false;
let runnerAge = 36;
if (runnerAge > 18) {
if (earlyRegistration) {
console.log(‘You will race at 9:30 am, your number is ’ + (raceNumber + 1000))
} else if (!earlyRegistration) {
console.log(Late adults run at 11:00 am, your number is ${raceNumber}.)}
}
else if (runnerAge < 18) {
console.log(Youth registrants run at 12:30 pm (regardless of registration), your number is ${raceNumber})
}
else if(runnerAge === 18) {
console.log(‘See the registration desk’)
}
console.log(’ ');

/* second version
let raceNum = Math.floor(Math.random() * 1000);
let earlyReg = false;
let runnerAg = 67;
(runnerAg > 18 && earlyReg) ? console.log(‘You will race at 9:30’); raceNum += 1000 : (runnerAg > 18 && !earlyReg) ? console.log (‘You will race at 11:00’) : (runnerAg < 18) ? console.log(‘You will race at 12:30’) : (runnerAg === 18) ? console.log(‘See the registration desk’);
console.log(` . Your race number is ${raceNum}
*/