Code Challenges: Javascript Fundamentals Proper use of else if

Here is a link to the exercize:

And here is my code so far:

const lifePhase = age => { 
  if (0 <= age <= 3)
    {return 'baby'};
  else if (4 <= age <= 12)
    {return 'child'}; 
 else if (13<= age <= 19) 
    {return 'teen'}; 
  else if(20 <= age <= 64) 
    {return 'adult'}; 
  else if (65 <= age <= 140)
    {return 'senior citizen'}
  else {return 'This is not a valid age.'} }

The error message I am getting is “unexpected token else.” So, my question is: why is my code editor not allowing me to use “else if” in this circumstance? Would I want to use multiple if statements instead?

Unexpected token tells us that you have a character out of place.

Take a look at some of your past else if statements. Is there a character that shouldn’t be there, in the wrong place or maybe even missing?

1 Like