Basic JavaScript - Chaining If Else Statements

Is my formatting the problem? i notice in the example it has the { at the end and the other } at the beginning of the next line?

  **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"};

// Only change code above this line
}

testSize(7);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36 Edg/104.0.1293.54

Challenge: Basic JavaScript - Chaining If Else Statements

Link to the challenge:

Your formatting with the {} is strange and non-standard, but technically functional. It is your placement of the ; that is wrong.

You really should follow standard formatting conventions. It helps others be able to understand your code. Making code that other humans understand is important.

brackets go outside semicolon! Got it, got lost in the data

1 Like

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