CJCoding With Joseph
15free / daySign inCreate account

Reverse the order of the <li> items inside the list with id="ranking" so the list reads "Third", "Second", "First". Re-appending an existing element MOVES it to the end, so appending the items in reversed order reverses the list.

Platform-Provided HTML (READ-ONLY):

<ul id="ranking">
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
</ul>

Steps: 1. Get the list, then copy its children into a real array with Array.from(list.children). 2. Reverse that array. 3. Loop over it and appendChild each <li> back onto the list.

Expected output

<ul id="ranking">
  <li>Third</li>
  <li>Second</li>
  <li>First</li>
</ul>

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