Skip to content
Advertisement

In JavaScript I can’t seem to make an if statement for if an Boolean is True/False

I’m trying to make a server, but I keep getting Syntax Error: "unexpected identifier"… I have done things like this:

if (AFK === true

alert("server AFK")

}
if Boolean(AFK)

alert("server AFK")

}
if (AFK

alert("server AFK")

}

The same error comes up…

I have a Boolean as well, so I had to put this:

var AFK = true

It is a thing to tell you if the server is AFK or not. The server is NOT working yet, I’m just seeing some errors with detecting boolean values…

Any way you could help?

Advertisement

Answer

The syntax is:

if (condition)
   statement1

So you should change it to:

if (AFK === true) {
  alert("server AFK")
}
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement