JavaScript Output — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Output 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
Write plain text
easy10 minPut the word "plain" into #out using textContent.
- 2
Write markup safely
easy10 minShow the literal text "<b>raw</b>" without it becoming bold.
- 3
Render real markup
easy10 minUse innerHTML so the word "bold" renders inside a <b> tag.
- 4
Show a number
easy10 minShow the result of 9 plus 6.
- 5
Replace existing text
medium10 minOverwrite whatever #out currently holds with "replaced".
Find the bug(5)
- 1
Fix the appended text
easy8 minUsing += keeps the old placeholder and the stale label instead of replacing everything.
- 2
Fix innerHTML used for plain text
easy8 minThe tags render instead of showing literally.
- 3
Fix the missing space
easy8 minThe two words are joined with no space between them.
- 4
Fix the value property
easy8 minvalue only works on form fields, not a paragraph.
- 5
Fix the missing conversion
easy8 minThe sum is joined as text because one side is a string.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace