5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Type Conversion lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Convert the text and add eight to it.
Convert a number to a string and report its type.
Report what Boolean gives for an empty string.
Report a message when the text cannot become a number.
Convert both inputs before adding them.
Text values join with plus rather than adding.
The join has already happened before the conversion.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceA failed conversion gives NaN, which must be checked for.
String works on null, but toString throws.
Number of an empty string is 0, not NaN.