# Please make sense of this

Tell us what’s happening:
I just looked at the video. This is too simple to be useful. What point are you making. Just saying >100 is >100; >10 is >10. Surely > 110 is also >100 but thats not allowed. The the 10 is there on its own with no if statement but is shows up in the video. I am missing something or you guys are just making this up to suite yourselves.

function testGreaterThan(val) {
if (val > 110) {  // Change this line
return "Over 100";
}

if (val >11) {  // Change this line
return "Over 10";
}

return "10 or Under";
}

testGreaterThan(10);

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

Challenge: Comparison with the Greater Than Operator

It’s supposed to be simple, it’s the very, very basics. You are being asked to check if val is greater than 100 in the first block, if val is greater than 10 in the second block. Not greater than 110, or 11

The point is that you understand what the > operator does (tests if the value on its left hand side is greater than the value on its right hand side)

Okay, if you say so.

So the function takes a number (val). If the number is greater than 100, the string “Over 100” is returned. Then if that isn’t the case, goes to the next if. If the number is greater than 10, the string “Over 10” is returned. Then if that isn’t the case, the number must be less than ten, so it goes to the final line and “10 or under” is returned.

If you put val > 110 in the first block and val > 11 in the second, as you have in your code, the function will return the wrong result:

• if you run testGreaterThan(101), you will get the return value “Over 10”, because 101 is not greater than 110.
• if you run testGreaterThan(11) you will get the return value “10 or under”, because 11 is not greater than 11.

Both of those answers are wrong, so the tests will fail: the return values should have been “Over 100” and “Over 10” respectively

Yes we have covered this; sorry to be pestering you.

the issue here is that if for example the input of the function is 101 (so if val has value of 101), it will not return "Over 100" because 101 > 110 is false

So val >120 would be fine because it is >110?
I have been told to put val >100 so that’s what I have done.

no you need to have a condition that will correctly return Over 100 when the value is over 100, so it needs to return true for val having values of 101, 102, 103, etc

if you write if (val > 120) {...} it will be true only for 121 and above
you are still missing the correct condition for values 101-120

Thanks Ieahleen, I revisited the exercise and created a new question, checking my current understanding.

Tell us what’s happening:
I have been going back and forth on this question to understand FCC exercise syntax. I have added comments to the exercise to show my current understanding. Am I on the right track.
Sorry to be taking up so much of your time but I need to be clear to move forward.

function testGreaterThan(val) {
if (val >100) {  // Change this line
return "Over 100";//Inside the function block, returns if true.
}

if (val > 10) {  // Change this line
return "Over 10";//second condition,new question.
}

return "10 or Under";//? Is this considered outside the function block??
}

testGreaterThan(2578);// I changed the 10 it still works, get a tick.

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

Challenge: Comparison with the Greater Than Operator

1 Like

no, look at the closing }, it’s after this return statement, so it is also inside the function

important note: a return statement outside a function will cause a syntax error

So what does the "10 or under " relate to. It just seem to be sitting out there orphaned. What’s it’s role, meaning, function. What should we be learning about it?

I might be in the wrong but
It’s the leftover value of the if else syntax
we already assigned the other 2 which are both the val above 11
so the leftover takes what is left everything bellow 11
and returns to tell u that

Only one return statement inside a function gets executed.

Which means that if the two if statements above fail, the number cannot be above 10, in which case we simply return "10 or under".

Since this is obvious, as the condition for

> 10

has failed, we do not have to use an if block to check for the fact.