Chaining If Else Statements

I am doing the JS lesson “Chaining If Else Statements” and I’m using this code and it always returns “Huge” no matter what my input is.


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

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

I can’t tell what is wrong with my code. Any help?

replace testSize with num, in your case testSize is undefined those it will always execute else statement and return “Huge”

Or create testSize variable var testSize = num; and your code will work.

As @mdivani said, testSize is the name of the function and num is your variable.
What happens is that when you call:
testSize(2);
Your program goes to the function with the name testSize and puts the number 2 in the first argument (num)
So from now on, inside your function, the variable num is the number 2 (or which ever number you might pass while calling the function)