Function, return, if/else


#1

What's wrong with my syntax??

function quarter(number) {
}
return number / 4

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


#2

Hi this part

function quarter(number) {
}
return number / 4

you should put return number / 4 inside the function quarter


#3

Thanks, but then I get this error:
SyntaxError: Illegal return statement


#4

can you post your new code?


#5

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

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


#6

you did wrong
your code should be like

function quarter(number) {

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

what @wizmarco said to you

@davidfw1866


#7

Sorry if I wasn't clear but you should change that

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

but

that

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

should be like that

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

#8

It still has mistakes:

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

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


#9

like that

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

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

you should only change the function not the if statement


#10

I'm having a problem as well. The syntax looks right, but it is not working.

> function quarter (number){
>     return number/4
> }


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

When I press submit it says "Oops, try again, Did you remember to call quarter() inside the if statement with a value that would cause it to print 'The statement is true'?

I have resolved the issue. It was the fact that I was putting in 9 as a parameter, not taking into account that it was going to be divided by 4. So I put 36 in there instead, and was able to get a true statement.