Lesson 2 of 15
OR & NOT Gates
OR and NOT Gates
The OR gate outputs 1 when at least one input is 1:
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
The NOT gate (inverter) has a single input and flips it:
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
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.