JavaScript Basics Playground

Learn by doing! Try out the fundamental syntax of JavaScript.

Conditional Logic: If / Else

The if/else statement runs a block of code if a condition is true, and another block if it's false. It's like making a decision.

let yourNumber = 15;
if (yourNumber > 10) {
  // This code runs if the number is greater than 10
} else {
  // This code runs otherwise
}

Try it yourself:

Result: