Functions, return and if / else .help!


#1

Why there were be the false?

var quarter = function(number) {
quarter = number / 4
};

if (quarter(12) % 3 === 0 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}


8. Functions, return and if / else/"There was a problem with your syntax."
#2

Could you be a little more descriptive about the problem?
The code doesn't seem to be bad so maybe the solution is just refreshing the page. If this does not help please post the error message and maybe a link to the exercise.

PS: @tarikjaber moved you over here because the problem seems to be similar.


#3

why doesn't this work
var quarter = function(number) {
return number/4 }

if (quarter(12) % 3 === 0 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}


#5

The solution is (The statement is false)
I substitute (return number / 4) to (quarter = number / 4)
why doesn't this work?


#6

return number/4 leads to quarter(input) having a value of input/4.
What quarter = number/4 does is replacing the function with number/4 making it unusable for later purpose and does not return any value so quarter(input) will have a value of undefined leading to the false option being picked.

How could I miss this? And how comes you made the same mistake?


#7

thanks,I understood. I just confused function and eqal.