We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Conditionals

if statements in JavaScript use parentheses around the condition:

if (height > 4) {
  console.log("You are tall enough!");
}

else if and else are supported as you might expect:

if (height > 6) {
  console.log("You are super tall!");
} else if (height > 4) {
  console.log("You are tall enough!");
} else {
  console.log("You are not tall enough!");
}

We'll cover some more of these, but for now, here are some common comparison operators:

  • === equal to
  • !== not equal to
  • < less than
  • > greater than
  • <= less than or equal to
  • >= greater than or equal to

Assignment

Fix the bug on line 12. If messageLen is less than or equal to maxMessageLen, the program should log "Message sent"; otherwise, it should log "Message not sent".