Your function is clearly not working as expected, because you are using a switch
the wrong way.
First of all, you are switching using the function itself as an expression
switch (isGreaterThan) {
Then, you are comparing it with another expression
case numberOne > numberTwo:
This is the equivalent of
if ( isGreaterThan == (numberOne > numberTwo))
And this check will never be true, because isGreaterThan
is not even a boolean, but (numberOne > numberTwo)
is
So this switch will always fallback to the default statement
default:
return false;
break;
That's why this function will always return false
As already mentioned from others, your function could work in this simple form
function isGreaterThan (numberOne, numberTwo) {
return numberOne > numberTwo;
}
Now, if you want an advise, I really think you don't understand how switch
works, so please take a step back and learn how it's supposed to work. There was really no reason to use switch in this case.
By the way, a ternary operator (as mentioned in the title) in your case would work like
(numberOne > numberTwo) ? true : false