I dont understand how to call a function in an if/else statement


#1

it's telling me I have an unexpected token


#2

Its not so nice if he is telling you that :sunny:

But without any code of you we dont can help you :wink:


#3

the code is this

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

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


#4

So first of all, my english is not the best - second language - but I will try to explain the best I can :
When you create a function, cs it's a function it has parentheses non matter what : function(), then if your function need to use/bring other parameter, you will specify them in the () of your function : function(number). Then, since it's a function you have to set what the function will do in the {} so : function(number) { //run this code };
I remember I passed that one and I dont have the instructions on top of my head but it should look more like this :
var quarter = function(number) {
var t = number / 4;
return t;
};
if (quarter(your_number) % 3 === 0) { // eg. quarter(12)
console.log("The statement is true");
} else {
console.log("The statement is false");
}
Tell me if it helps.


#5

just do console.log(quarter(stuff that defines quarter))
tell me if this helps :smile:


#6

Yes this helped. thanks :+1: