Uitdaging: Vergelijk Variabelen in JavaScript
Taak
We hebben drie variabelen in deze taak: a = 33
, b = 26
, en c = "26"
. We zullen verschillende vergelijkingsoperaties op deze variabelen uitvoeren.
- Controleer of
a
gelijk is aanb
. - Controleer of
b
strikt gelijk is aanc
. - Bepaal of
a
groter dan of gelijk aanc
is. - Ontdek of
b
kleiner is danc
. - Controleer of
a
groter is danb
EN ofb
gelijk is aanc
. - Controleer of
a
gelijk is aanb
OF ofc
kleiner is dana
.
let a = 33; let b = 26; let c = "26"; console.log(a ___ b); // Task 1 console.log(b ___ c); // Task 2 console.log(a ___ c); // Task 3 console.log(b ___ c); // Task 4 console.log(a ___ b && b ___ c); // Task 5 console.log(a ___ b || c ___ a); // Task 6
De uitvoer moet zijn:
false
false
true
false
true
true
- Gebruik de vergelijkingsoperatoren:
==
,===
,>=
,<
,>
. - Gebruik de logische operatoren: EN (
&&
) en OF (||
).
let a = 33; let b = 26; let c = "26"; console.log(a == b); // Task 1 console.log(b === c); // Task 2 console.log(a >= c); // Task 3 console.log(b < c); // Task 4 console.log(a > b && b == c); // Task 5 console.log(a == b || c < a); // Task 6
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 3. Hoofdstuk 8