Basic JavaScript - Chaining If Else Statements

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

function testSize(num) {
  // Only change code below this line
if (num < 5); {
  return "Tiny"
} else if (num < 10); {
  return "Small";
} else if (num < 15); {
  return "Medium"
} else if (num < 20); {
return "Large"
} else {
  return "Huge"
}


  return "Change Me";
  // Only change code above this line
}

testSize(7);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15

Challenge: Basic JavaScript - Chaining If Else Statements

Link to the challenge:

Are you getting any errors running this code?

No need for a semicolon after an if statement. You can remove the semicolon after each of the if statements
However, you should try to put a semicolon at the end of return statements

Thanks, can you tell me when should i write the semi-colon in the code in genera, i saw people putting it after console.log, arrays, variables, if, for and more than that, can you provide me a knowledge to learn when to use it, and thanks for helping and for your time

Yes , and now the problem is solve, i shouldn’t put the semi-colon after the if statements , and thanks for your time

No problem! The semicolon is used to end a statement, sort of like how you put a period at the end of a sentence. As a general thing, you might put it at the end of something you want to happen, but not when you are making functions or defining conditions (except for loops, if you have gotten there in the lessons).
It’s better explained in this article from FCC:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.