JavaScript Forms and Inputs — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Forms and Inputs 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
Read an input value
easy10 minReport the value of the name field.
- 2
Set an input value
easy10 minChange the value to Grace and report it back.
- 3
Convert a number field
easy10 minRead the age, add five, and report the total.
- 4
Read a checkbox
easy10 minReport whether the checkbox is ticked.
- 5
Validate an empty field
medium10 minReport a message when the field holds only spaces.
Find the bug(5)
- 1
Fix the values joined instead of added
easy8 minAn input value is a string, so plus joins rather than adds.
- 2
Fix textContent used on an input
easy8 minAn input holds its contents in value, not textContent.
- 3
Fix the checkbox read with value
easy8 minvalue gives what the box submits, not whether it is ticked.
- 4
Fix the missing trim
easy8 minA field of spaces is being treated as filled in.
- 5
Fix the select read from the option text
easy8 minThe select's value is what should be reported, not the label the visitor sees.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace