8. Functions, return and if / else


Hello! I'm beginner in JavaScript ( and English ).
In order to understand difference between console.log and return, I typed a below code:

// Define quarter here.
var quarter = function (number){
    console.log (number / 4);

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


The console printed out it.

The statement is false

Why did the console print out them?
Especially, It's hard for me to understand why there are "The statement is false" and "-25".

I changed console.log to return and finished this section, however I don't understand the above printing out.

What did JavaScript calculate...?

I thank you for reading it through.


ignore -25, its a test case of the exercise for validation

to understand "The statement is false" run the following code:

var quarter = function (number){
    console.log (number / 4);
x = quarter(12)
console.log(x) // will log undefined

the problem is that your quarter function has no return keyword, so the default (undefined) is returned, which mean if we manually evaluate your if condition:

if (undefined % 3 === 0)

this is false.

your quarter function should return the quarter.


Thank you so much!
I could understand why the console printed out "The statement is false" and an importance of return keyword.