Arrow functions have an implicit return, which means if you don't wrap their body with {}
, then you don't need to use the return
keyword. Your function returns undefined
because you're not providing a return value. You need to either remove the curly braces or add a return
keyword:
function greater(n){
return (m)=>{return m>n};
}
One last thing to note, if you want to implicitly return an object, the curly braces will be treated as the function body and so nothing will be returned. In that case, you'd need to wrap the object in parentheses:
const wrong = () => { test: true }
const right = () => ({ test: true })