Challenge: Compare Variables in JavaScript
Task
We have three variables in this task: a = 33, b = 26, and c = "26". We will perform various comparing operations on these variables.
- Check if
ais equal tob. - Check if
bis strictly equal toc. - Determine if
ais greater than or equal toc. - Find out if
bis less thanc. - Check if
ais greater thanbAND ifbis equal toc. - Check if
ais equal tobOR ifcis less thana.
12345678910let 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
The output should be:
false
false
true
false
true
true
- Use the comparison operators:Β
==,Β===,Β>=,Β<,Β>. - Use the logical operators:Β ANDΒ (
&&) andΒ ORΒ (||).
12345678910let 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
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 8
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Can you explain why the output for each comparison is true or false?
What is the difference between `==` and `===` in JavaScript?
Can you show how these comparisons would work if `c` was a number instead of a string?
Awesome!
Completion rate improved to 2.33
Challenge: Compare Variables in JavaScript
Swipe to show menu
Task
We have three variables in this task: a = 33, b = 26, and c = "26". We will perform various comparing operations on these variables.
- Check if
ais equal tob. - Check if
bis strictly equal toc. - Determine if
ais greater than or equal toc. - Find out if
bis less thanc. - Check if
ais greater thanbAND ifbis equal toc. - Check if
ais equal tobOR ifcis less thana.
12345678910let 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
The output should be:
false
false
true
false
true
true
- Use the comparison operators:Β
==,Β===,Β>=,Β<,Β>. - Use the logical operators:Β ANDΒ (
&&) andΒ ORΒ (||).
12345678910let 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
Everything was clear?
Thanks for your feedback!
SectionΒ 3. ChapterΒ 8