8/13 Introduction to Functions in JS


#1

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

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

Can someone please help me here, i have no idea what is wrong, i need to finish this by tomorrow


#2

Hi Max,

you are missing a part of the quarter function, it should be taking the number and dividing it by 4 like this

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

then you want the IF statement to be TRUE, so you need a number that when a quarter of it is divisible by 3 is 0. So I did -

if (quarter(60) % 3 === 0 ) {
  ...
}

because a quarter of 60 is 15, 15 is equally divided by 3 leaving a remainder of 0 (which makes the condition true)

NOTE - % means Modulus (division remainder) in javascript

Hope that helps

Thanks

Keith


#3

what is wrong with mine its in spanish but same syntaxis

var unCuarto = function (number) {

return number/4;
};

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


#4

Seems to be ok did you try to refresh the page? What is the error message you receive?


#5

El asunto es que debes darle un valor numérico que dividido por 3 sea igual a 0.

Yo simplemente coloqué 0 y me funcionó.

var unCuarto = function (numero){
return numero / 4
};
if (unCuarto(0) % 3 == 0 ) {
console.log("La sentencia es verdadera");
} else {
console.log("La sentencia es falsa");
}

Suerte!