Help

Hello. Could you help me figure out what is wrong?
Welcome to the Get Help category!

This is where you can ask questions about your code. Some important things to remember when posting in this category :slight_smile:

  • Learn how to ask a good question and get a good answer!
  • Remember to include a link to the exercise you need help with!
  • If someone answers your question, please mark their response as a solution :white_check_mark:
  • Once you understand a new concept, come back and try to help someone else!

Please post a link to this exercise so we may review the instructions and criteria.

oh i thought i did. ill paste here.

JAVASCRIPT SYNTAX, PART I

Race Day

Codecademy’s annual race is just around the corner! This year, we have a lot of participants. You have been hired to write a program that will register runners for the race and give them instructions on race day.

As a timeline, registration would look like this:registration-timeline

Here’s how our registration works. There are adult runners (over 18 years of age) and youth runners (under 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 we didn’t plan for runners that are exactly 18! We’ll handle that by the end of the project.

If you get stuck during this project or would like to see an experienced developer work through it, click “ Get Help “ to see a project walkthrough video .

Tasks

9/9 Complete

Mark the tasks as complete by checking them off

Race numbers are assigned randomly. We’ve provided the necessary code at the top of the file.

Check off this task after reading that line.

You can read the hint if you want to learn how it works!

Stuck? Get a hint

Create a variable that indicates whether a runner registered early or not.

Set it equal to a Boolean value. You’ll change this later as you test different runner conditions.

Stuck? Get a hint

Create a variable for the runner’s age and set it equal to a number.

You’ll change this later as you test different runner conditions.

Stuck? Get a hint

Create a control flow statement that checks whether the runner is an adult AND registered early.

Add 1000 to their raceNumber if this is true.

Stuck? Get a hint

Create a separate control flow statement below the first (starting with if again). This statement will check age and registration time to determine race time.

For runners over 18 who registered early, log a statement to the console telling them that they will race at 9:30 am. Include their raceNumber .

Stuck? Get a hint

“Late adults run at 11:00 am”

Since we already checked for early adults we can write a statement like this: else if runner is over 18 AND did not register early they will race at 11:00am

Write the corresponding else if statement.

Within that, log a string to the console telling them that they will race at 11:00 am. Include their raceNumber .

Stuck? Get a hint

“Youth registrants run at 12:30 pm (regardless of registration)”

For people who are under 18, log a statement to the console telling them that they will race at 12:30 pm. Include their raceNumber .

Stuck? Get a hint

Enter different combinations of values for the two variables you created and run your code several times. Verify that the correct statements are printing to the console!

You can check your work using the examples provided in the hint.

Stuck? Get a hint

Don’t forget about runners exactly 18 years old!

Add an else statement that logs a statement to the console telling the runner to see the registration desk.

You should be receiving an unexpected token "else" error message. The syntax for if…else if…else is as follows:

if(condition){
//code
}
else if (otherCondition) {
//code
}
else{
//more code
}

Notice the lack of semi colons?

1 Like

The trouble with a random race number is that duplicates can occur. What if we start with 101 and go up from there in sequence?

let raceNumber = 101

Now every racer automatically gets a number from that sequence. As they register we increment raceNumber. This is not conditional.

The condition is time of registration and over 18. Like you have, we add 1000 to their race number.

Examining the start times, the early start time is only adults and also tied to the above early condition so we can toss it in with that action.

Now we’re left with just one other condition, to set the race times. To be fair, exactly 18 would be lumped in with this but the instructions have something else in store, just for practice.

2 Likes

thanks.didnt know
i was not supposed to type ; there.
great to know and thanks for help.

1 Like

thanks for help!
i solved the problem!

1 Like

As we race ahead (pun intended) we learn a whole lot more, all of which will take some work to gain competency. It will be beneficial to stop and experiment at each step. Play with EVERY lesson, and find docs and good examples to bookmark at each one. Learn, practice, review, read, practice, review, experiment, review, develop, review, … The process never changes, only evolves.

https://repl.it/@mtf/Race-Coordinator

A work in progress…


Sample output for 25 racers…

0930h [
  '1104', '1105',
  '1107', '1108',
  '1115', '1116',
  '1119', '1122',
  '1123'
]
1100h [
  '103', '106', '109',
  '110', '112', '113',
  '118', '120', '124',
  '125'
]
1230h [ '101', '102', '114', '117', '121' ]
not in race [ '111' ]
1 Like