Read the text of the element with class note.
Acceptance criteria
- 1.#out should show A note.
JavaScript Tutorial · JavaScript DOM
These 10 tasks go with the JavaScript DOM Selectors 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 finds elements on a page with getElementById, querySelector and querySelectorAll.” .
1.Select by classexercise · easy · 10 min
Read the text of the element with class note.
Passes when: #out should show A note.
2.Count matching elementsexercise · easy · 10 min · practice plan
Report how many paragraphs have the class item.
Passes when: #out should show 3.
3.Select the first matchexercise · easy · 10 min · practice plan
querySelector returns only the first match, so report its text.
Passes when: #out should show First.
4.Search inside an elementexercise · easy · 10 min · practice plan
Find the span inside the box, ignoring the one outside it.
Passes when: #out should show Inside.
5.Select by attributeexercise · medium · 10 min · practice plan
Find the input whose type is email and report its value.
Passes when: #out should show ada@example.com.
6.Fix the missing dotbug fix · easy · 8 min
querySelector needs a dot to search by class.
Passes when: #out should show A note.
7.Fix querySelector used for a countbug fix · easy · 8 min · practice plan
querySelector returns one element, which has no length.
Passes when: #out should show 3.
8.Fix the id selector without a hashbug fix · easy · 8 min · practice plan
querySelector treats a bare name as a tag name.
Passes when: #out should show Target.
9.Fix the search that ignored the boxbug fix · easy · 8 min · practice plan
The search covers the whole page instead of just the box.
Passes when: #out should show Inside.
10.Fix the unchecked resultbug fix · easy · 8 min · practice plan
A failed lookup gives null, which must be handled.
Passes when: #out should show nothing matched.
Between them these tasks cover querySelector, querySelectorAll and getElementById.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.