InfoparkDailyCAREER TOOLS

JavaScript · Lesson 3 of 8

Operators & conditions

Arithmetic, comparison, logical operators and if / else.

Arithmetic: + - * / %. Comparison: === !== < > <= >=. Always use === (strict equality) rather than ==, which converts types first ("5" == 5 is true!).

Logical: && (and), || (or), ! (not).

if (score >= 60) {
  …
} else if (score >= 40) {
  …
} else {
  …
}

The ternary cond ? a : b is a short if/else for values.

Try it yourself

Edit the code and press Run (or Ctrl/⌘ + Enter). Code runs only in your browser, in a sandbox.

Key points

  • Use === not ==.
  • && and || combine conditions.
  • Ternary for simple value choices.

Quick check

What is "5" === 5?

Practice task

Write code that prints 'Fizz' for multiples of 3, 'Buzz' for 5, 'FizzBuzz' for both, for numbers 1–20.

Interview corner

== vs ===?

== converts types before comparing ("5" == 5 is true). === compares value and type, so it's predictable — use it.

What are truthy and falsy values?

Falsy: false, 0, -0, 0n, '', null, undefined, NaN. Everything else is truthy.

Further reading

Official documentation, linked for deeper study. These are outside sites; this lesson's text is our own.

Original lesson written by the InfoparkDaily team · © 2026 InfoparkDaily · Free to learn — no paid course or subscription.