PLEASE HELP exercise 8 : functions, return and/if else


#1


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


SyntaxError: Unexpected token if

Im not sure what im doing wrong with this exercise.


// Define quarter here.
var quarter = function (number)


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


#2

Try this:

// 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");
}

Problem is, yoou did not return the number / 4


#4

SyntaxError: Illegal return statement

This is the code I put

var quarter = function(number) {
return number / 4;
}
if (quarter(-100) % 3 === 0 ) {
console.log("The statement is true");
return number / 4;
} else {
console.log("The statement is false");
}


#5

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