JavaScript == vs === — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript == vs === lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Compare loosely
easy10 minReport whether a string and a number are loosely equal.
- 2
Compare strictly
easy10 minReport whether they are strictly equal.
- 3
Check for null or undefined
easy10 minUse one check that catches both.
- 4
Compare two objects
easy10 minReport whether two identical-looking objects are equal.
- 5
Convert then compare
medium10 minConvert the text before comparing it strictly.
Find the bug(5)
- 1
Fix the loose comparison
easy8 minA string and a number should not be treated as equal.
- 2
Fix the object compared by contents
easy8 minTwo objects are equal only if they are the same object.
- 3
Fix the strict null check
easy8 minStrict equality misses undefined when checking for null.
- 4
Fix the loose comparison against text
easy8 minThe number should not be treated as equal to the string.
- 5
Fix the empty string compared to zero
easy8 minLoose equality says they are equal, which is not wanted.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace