Question about true/false (7. function declarations)

function isGreaterThan (numberOne, numberTwo){
  if(numberOne > numberTwo){
    return true;
  } else {
    return false;

isGreaterThan(5, 1);

This returns false in the console even if I change 1 and 5 and 5 and 1. The lesson says I passed but I’d rather not move on until I know why it won’t change to true.

Edit: Asked a co-worker and the reason is because the you’re not calling an actual function since you’re comparing null to null. You have to store the function in another variable like

var result = isGreaterThan(1,5);

And that will get you the correct results.

You should pass two parameters here

isGreaterThan(5, 1); // This executes the function but there is no output command. So delete this.

console.log(isGreaterThan(5, 1)); // This executes the function with the arguments and prints the result on console.

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