CJCoding With Joseph
15free / daySign inCreate account

Select ALL list items inside the list with id="menu" and add the class "nav-item" to each one.

Platform-Provided HTML (READ-ONLY):

<ul id="menu">
  <li>Home</li>
  <li>About</li>
  <li>Contact</li>
</ul>

Steps: 1. Use document.querySelectorAll("#menu li") to select every list item. 2. Loop over the result with forEach and call classList.add("nav-item") on each item.

Expected output

All three <li> elements gain class="nav-item"

= newline. No newline after the last line.

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