Can´t get this right, but why?!?!


#1

Hi guys,

I´m stuck with the if/else (else if) conditions, everytime i write the code my else (or else if) turns red and gives me an error...and if i compare my code to the solution code it´s exactly the same (at least it looks the same)... so im kinda frustrated and would apreciate help

var moonPhase = 'full';

if (moonPhase === 'full'); {
  console.log('Howwwwlll!!');
} else {
  console.log('I swear I am not a werewolf...'); 
}


#2

erase that semicolon!

if/else syntax..

if (condition) {
    //your code
} else {
    //your code
}

you posted this in wrong section!(java)


#3

Thanks for the quick Response...when/ how exactly should i use the semicolons?


#4

Semicolons will be used for (after them when they finish) statements.
Statements - small commands .

But you have to follow the syntax of language..

as I already pointed that

if (condition) {
    //your code
} else {
    //your code
}

and you can see there is no semicolon just after if or else?right!

but say it has a statement inside it.

if (condition) {
    console.log("GreenTree"); // you can see I used semicolon,right?
} else {
    //your code
}

#5

Got it!
Thank you:pray:


#6

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