JavaScript Data Types — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Data Types 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
Report a number's type
easy10 minUse typeof to show the type of the value 7.
- 2
Report a string's type
easy10 minUse typeof to show the type of "hello".
- 3
Convert a string to a number
easy10 minTurn the string "25" into a number and add 5 to it.
- 4
Convert a number to a string
easy10 minTurn 99 into a string and show its length.
- 5
Check for an array
medium10 minShow whether [1,2,3] is an array, as true or false.
Find the bug(5)
- 1
Fix the string addition
easy8 minAdding two numeric strings joins them instead of summing them.
- 2
Fix the typeof check on an array
easy8 minThis reports "object" instead of confirming an array.
- 3
Fix the wrong equality
easy8 minLoose equality makes this comparison true when it should be false.
- 4
Fix the undefined property read
easy8 minReading a missing property shows undefined instead of the count.
- 5
Fix the number that became text
easy8 minThe total is joined as text because one value is a string.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace