Introduction to functions:, return and if / else


#1

Functions, return and if / else

SyntaxError: Unexpected token


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




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


#2

if (quarter(6) % 3 === 0 ); <--------- remove semicolon


#3

there is still an error


#4

to add to @kalebmfratello answer, a normal function has curly brackets to mark the end and start of the function:

var example = function(){

}

they are missing in your case, and your function also has an unnecessary semi-colon


#5

Do you mean like this? cause there is still and error

// Define quarter here.
var quarter = function(number);
{
if (quarter(6) % 3 === 0 )
{
console.log("The statement is true");
}
else
{
console.log("The statement is false");
}
}


#6

var quarter = function(number); <------- remove this semicolon too and you should be fine
{


#7

There we go! thank you!


#8

There we go its working when i deleted the semi colon! thank you!


#9

i already mentioned the semi-colon which was wrong, and it wasn't in my code:

i was hoping you would see it, but good that you resolved it :slight_smile:


#10

xD i thought you meant th eother semi colon


#11

I was about to say, thank @stetim94, he already mentioned the last error.


#12

@kalebmfratello already covered that one, no need to mention it again.


#13

lol thanks anyway, atleast i understand now and its that that matters


#14