Read the heading text and report it in #out.
Acceptance criteria
- 1.#out should show Welcome.
JavaScript Tutorial · JavaScript DOM
These 10 tasks go with the JavaScript DOM 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: “The DOM is the browser's model of a page, and JavaScript uses it to read and change the page.” Read the chapter.
1.Read text from the pageexercise · easy · 10 min
Read the heading text and report it in #out.
Passes when: #out should show Welcome.
2.Change text on the pageexercise · easy · 10 min · practice plan
Change the paragraph text to Updated, then report what it now says.
Passes when: #out should show Updated.
3.Count child elementsexercise · easy · 10 min · practice plan
Report how many child elements the box holds.
Passes when: #out should show 3.
4.Check an element existsexercise · easy · 10 min · practice plan
Report found when the element is there and missing when it is not.
Passes when: #out should show missing.
5.Read the body tag nameexercise · medium · 10 min · practice plan
Report the tag name of the body element.
Passes when: #out should show BODY.
6.Fix the hash in getElementByIdbug fix · easy · 8 min
getElementById takes a bare id, without the hash.
Passes when: #out should show Welcome.
7.Fix the text read from the wrong elementbug fix · easy · 8 min · practice plan
The heading is being read instead of the note.
Passes when: #out should show Original.
8.Fix the change that never happenedbug fix · easy · 8 min · practice plan
The new text is worked out but never put on the element.
Passes when: #out should show Updated.
9.Fix childNodes used for a countbug fix · easy · 8 min · practice plan
childNodes includes text nodes, so the count is wrong.
Passes when: #out should show count 3.
10.Fix the missing element guardbug fix · easy · 8 min · practice plan
A missing element gives null, so it must be checked before use.
Passes when: #out should show missing.
Between them these tasks cover document object, Reading the page and Changing the page.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.