Javascript if


#1

i don’t understand why this code doesn’t work. I would be happy if somebody could help me:

const finalGrade = ( n1, n2, n3 ) => {if ((n1 < 0 || n1 > 100) || (n2 < 0 || n2 > 100) || (n2 < 0 || n2 > 100)) {return ‘error’} else {
return (n1 + n2 + n3) /3 };}
;

console.log (finalGrade (5, 7, 7));

const word = finalGrade;

if (word >= 6) {
console.log(‘f’) ;
}

else if (word >= 10) {
console.log(‘a’)
}
else { console.log(‘error’)};

the answer that I got, is :
6.333333333333333
error

so the first part is correct, just the second not…

Thanks!


#2

Did you mean to invoke the function? The above line only assigns a reference to the function.