5 hands-on exercises and 5 find-the-bug challenges for the JavaScript String trim lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Remove the spaces around the name.
Report that a field of spaces is really empty.
Add a leading zero to the minutes.
Pad both parts to make a proper time.
Show only the last four digits.
A field of spaces is being treated as filled in.
trim returns a new string and does not change the original.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceThe zero belongs at the front.
padStart is a string method, so the number needs converting first.
The mask needs to reach twelve characters.