Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Set Text Content

DOM & Eventseasy

Course · Section 7: JavaScript in the Browser: DOM and Events · Lecture 76: Selecting and Manipulating Elements

The page has an empty `<h1 id='title'>`. Set its text content to `Hello`.

Sample tests

Input: the heading text is 'Hello'
Output: assertion passes

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Using innerHTML for plain text invites injection bugs; prefer textContent.

Learning resources

  • MDN: Node.textContent
Approach & explanation (try first)

textContent sets the element's text safely and directly.

Loading...
⌘/Ctrl + Enter

Run your code to see results.