Report the value of the name field.
Acceptance criteria
- 1.#out should show Ada.
JavaScript Tutorial · JavaScript DOM
These 10 tasks go with the JavaScript Forms and Inputs chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “JavaScript reads and sets form values through the value and checked properties.” .
1.Read an input valueexercise · easy · 10 min
Report the value of the name field.
Passes when: #out should show Ada.
2.Set an input valueexercise · easy · 10 min · practice plan
Change the value to Grace and report it back.
Passes when: #out should show Grace.
3.Convert a number fieldexercise · easy · 10 min · practice plan
Read the age, add five, and report the total.
Passes when: #out should show 25.
4.Read a checkboxexercise · easy · 10 min · practice plan
Report whether the checkbox is ticked.
Passes when: #out should show true.
5.Validate an empty fieldexercise · medium · 10 min · practice plan
Report a message when the field holds only spaces.
Passes when: #out should show please enter a name.
6.Fix the values joined instead of addedbug fix · easy · 8 min
An input value is a string, so plus joins rather than adds.
Passes when: #out should show 25.
7.Fix textContent used on an inputbug fix · easy · 8 min · practice plan
An input holds its contents in value, not textContent.
Passes when: #out should show Ada.
8.Fix the checkbox read with valuebug fix · easy · 8 min · practice plan
value gives what the box submits, not whether it is ticked.
Passes when: #out should show true.
9.Fix the missing trimbug fix · easy · 8 min · practice plan
A field of spaces is being treated as filled in.
Passes when: #out should show please enter a name.
10.Fix the select read from the option textbug fix · easy · 8 min · practice plan
The select's value is what should be reported, not the label the visitor sees.
Passes when: #out should show lg.
Between them these tasks cover value, checked and Validation.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.