Chaining If Else Statements (CHALLENGE)

Tell us what’s happening:
what part of the last “else” isnt fitting here? test wont pass final 2 conditions, made several checks and then checked for help, answers look the same right?
also, system keeps bringing up a syntax error at the bottom AFTER “testSize(7);” where is shows the arrow pointing at a space after the final code, but nothing is there and i cant delete the space. “unexpected token”. how do you fix that…?

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 (null < 20) {
  return "Large";
} else {
  return "Huge";
}
  // Only change code above this line


// Change this value to test
testSize(7);

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/chaining-if-else-statements/

syn1

syntax error space thing**

Hi,

You forgot to close the brackets after the function declaration.

Your code now looks like:

function testSize(num) {
  
// some code ...

testSize(7);

but it should look like:

function testSize(num) {
  
// some code ...

}

testSize(7);

Fix it and then you will be able to work with your code further. :slight_smile:

bugger okay i see that, my bad. however i still have that weird syntax error at the bottom (see my first reply with pic). i havent edited anything below the lines, and i cant do any deleting after the “;” where that empty token would be. ideas? thanks :))

Once you add that missing bracket you will see this:

%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%BD%D1%8F

yeah i got that, did it. its not the issue though that the test is pointing to

What error do you mean?

Could you please send the updated version of you code and the error?

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 (null < 20) {
  return "Large";
} else {
  return "Huge";
}
}![syn1_LI|419x160](upload://yt5iWsC9CZnZjGNtBEeQte6c00j.jpeg) 
  // Only change code above this line


// Change this value to test
testSize(7);

syn1

disregard pic upload attempt from last post, its this

Okay, take your code, push closing bracket } before the testSize(7); and you will fix this error.

Isn’t it clear?

I think the word null should be num.

else if (null < 20) {
return “Large”;
}

Hope it helps.

1 Like

Hi ZTD,
There are TWO mistakes in your code:

  1. Try changing this:
    else if (null < 20) { return "Large";

you used null instead of num

  1. You did not use curly brackets ( } ) to close your function. Close it here:
    else {
    return "Huge";
    }
    }

I hope this helps

1 Like

ight the Null got me on the damn auto fill, fixed that and the braces and it has still given me the shitty syn error. copy pasted after reloading the page and now it works. i guess i had just effed with it so much it got messed up somewhere else and jammed up even though the then fixed code was right (since pasted it worked) anywho, i just got to posting this and now im 4 challenges passed this one now. thanks y’all for fixing my stupid lol