8. Functions, return and if / else


#1

Hi everyone, I kindly need your help with this one:

https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/1/3?curriculum_id=506324b3a7dffd00020bf661#

Think, I misunderstood the task, 'cause it says "Call the function inside the if statement's condition (and put in a parameter value!) such that "The statement is true" is printed to the console."

So, when it runs the code it does print "The statement's true", however,
I get : "Hmm, it looks like your quarter function doesn't return -25 for -100."

Why -25 for -100? It seemed to me that it wasn't a part of the task.

var quarter = function(number) { 
   return number % 3; 
}



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

#2

UPD: It's fine now, case solved:

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

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


#3

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