Functions, return and if/else. I'm stuck!


What is wrong with my code? It looks ok maybe an idiot mistake?

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

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


Any help is appreciated!

EDIT: My error message is "Hmm, it looks like your quarter function doesn't return -25 for -100."


In this exercise, do the instructions ask for the function to use a return statement or console.log after the number gets divided by 4?


Use return instead of console.log()


This may sound silly, but from the error message it looks like the exercise instructions asked you to use -100 as the value for the parameter (number), but you used 12 instead... Try going back and reading the instructions for the exercise again; maybe you just chose a different value than the question was specifically asking for (I've done that many times, much to my frustration.) When I ran your code with -100 as the value when calling the function, it gave me -25, so this is just a guess based off of the code you gave and the error message you provided-- Copying the instructions for the exercise to include with this question would be helpful so we could see exactly what it was asking you to do in the first place.

I hope this helps! If not, good luck!

PS. I think konaesan is correct in suggesting return instead of console.log, as well (just judging by the error message again).


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.