Put the word "plain" into #out using textContent.
Acceptance criteria
- 1.#out should show plain.
JavaScript Tutorial · JavaScript Introduction
These 10 tasks go with the JavaScript Output 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 output means displaying data or result using JavaScript. JavaScript can show output in different places, such as inside an HTML element, inside” .
1.Write plain textexercise · easy · 10 min
Put the word "plain" into #out using textContent.
Passes when: #out should show plain.
2.Write markup safelyexercise · easy · 10 min · practice plan
Show the literal text "<b>raw</b>" without it becoming bold.
Passes when: #out should show <b>raw</b>.
3.Render real markupexercise · easy · 10 min · practice plan
Use innerHTML so the word "bold" renders inside a <b> tag.
Passes when: #out should show bold.
4.Show a numberexercise · easy · 10 min · practice plan
Show the result of 9 plus 6.
Passes when: #out should show fifteen.
5.Replace existing textexercise · medium · 10 min · practice plan
Overwrite whatever #out currently holds with "replaced".
Passes when: #out should show replaced.
6.Fix the appended textbug fix · easy · 8 min
Using += keeps the old placeholder and the stale label instead of replacing everything.
Passes when: #out should show clean.
7.Fix innerHTML used for plain textbug fix · easy · 8 min · practice plan
The tags render instead of showing literally.
Passes when: #out should show <b>raw</b>.
8.Fix the missing spacebug fix · easy · 8 min · practice plan
The two words are joined with no space between them.
Passes when: #out should show output ready.
9.Fix the value propertybug fix · easy · 8 min · practice plan
value only works on form fields, not a paragraph.
Passes when: #out should show shown.
10.Fix the missing conversionbug fix · easy · 8 min · practice plan
The sum is joined as text because one side is a string.
Passes when: #out should show fifteen.
Between them these tasks cover textContent vs innerHTML and Writing to the page.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.