<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-javascript-functions/lessons/functions/exercises/function-expressions?action=lesson_resume&course_redirect=introduction-to-javascript
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
Rather than using an if/else statement in the “isGreaterThan” function, I’ve been simply returning the evaluation of the logical function. However, the exercise returns an error message asking: “Did you change function isGreaterThan(numberOne, numberTwo) {} to const isGreaterThan = (numberOne, numberTwo) => {}?” Is there a difference between the two? The first example below returned positive results in the previous exercises, so I’m not sure whether this is a limitation of the exercise, or whether there’s a difference between function expressions and function declarations.
This is the code I originally had entered (which returned the error message):
const isGreaterThan = (numberOne, numberTwo) => {
return (numberOne > numberTwo);
}
console.log(isGreaterThan(2,3));
and this is what I had to change it to (which returned no error):
const isGreaterThan = (numberOne, numberTwo) => {
if (numberOne > numberTwo) {
return true;
} else {
return false;
}
}
console.log(isGreaterThan(2,3));