8 Functions, return and if / else


#1

Here is my code:

// Define quarter here.
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");
}

I keep getting Error:Access is denied in console, and Oops, try again. Did you remember to call quarter() inside the if statement with a value that would cause it to print 'The statement is true'?

Looked around at other people's solutions and mine looks the same as other peoples!


#2

Refresh your page, then your browser if that doesn't work.


#3

the '===" means similar in value and type. your not doing anything that would give you remainder.


#4

His code is correct as === is used for comparison, and sorry but 0 is equal to 0.


#6

Could you explain this further. Because at the moment I'm not convinced that calling the function inside itself is a good idea as it will lead to an infinite recursion.


#9

I am also getting the same problem. my code is even similar to @zboulton code only with diff value for "quarter". I have even encountered this same problem during HTML and CSS hereby u write d ryt code and still get the error message. so I think you should try it on ur IDE and if it is ryt bcos I tried mine and it is correct. so I think it is the probs of the site.


#11

Just finished it, try to add some spaces to your code return number / 4;, see if that works!


#13

Your result of the remainder should be Zero, hence try 'return number / 4' and the quarter value should be 12
eg:
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");
}


#14

oh thanks a lot!! i just forgot to put somethng withn frst brackets :unamused: