CJCoding With Joseph
15free / daySign inCreate account

Create and Append New Element

Create a new paragraph element with the text "This paragraph was created with JavaScript!" and append it to the div with id="container".

Platform-Provided HTML (READ-ONLY):
<div id="container">
  <p>Existing paragraph.</p>
</div>

Steps:
1. Use document.createElement() to create a new <p> element
2. Set its textContent to "This paragraph was created with JavaScript!"
3. Use document.getElementById() to select the container
4. Use appendChild() to add the new paragraph to the container

Expected Output:

<div id="container">
  <p>Existing paragraph.</p>
  <p>This paragraph was created with JavaScript!</p>
</div>

= newline. No newline after the last line.

Hints4 available
Topics:
HTML DOM
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (clog, fn, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.