Lesson 2 of 15

OR & NOT Gates

OR and NOT Gates

The OR gate outputs 1 when at least one input is 1:

ABA OR B
000
011
101
111

The NOT gate (inverter) has a single input and flips it:

ANOT A
01
10

In JavaScript:

  • OR uses the bitwise OR operator |
  • NOT can be done with XOR: a ^ 1 (flips the last bit)
1 | 0  // 1
0 | 0  // 0
1 ^ 1  // 0  (NOT 1)
0 ^ 1  // 1  (NOT 0)

Your Task

Implement or(a, b) and not(a), then print:

  • or(0, 0), or(0, 1), or(1, 1)
  • not(0), not(1)
JavaScript loading...
Loading...
Click "Run" to execute your code.