CJCoding With Joseph
15free / daySign inCreate account

Create a Link Element

Create a new <a> element with href "https://example.com" and text "Visit", then append it inside the nav with id="nav".

Platform-Provided HTML (READ-ONLY):
<nav id="nav">
</nav>

Steps:
1. Create the anchor with document.createElement("a").
2. Set its href with setAttribute("href", "https://example.com") and its textContent to "Visit".
3. Append it with nav.appendChild().

Expected Output:

<nav id="nav">
  <a href="https://example.com">Visit</a>
</nav>

= 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.