Which fix removes the bug?
const items = document.querySelectorAll('li');
const texts = items.map((li) => li.textContent);
- Spread into an array first
- Use getElementsByTagName
- Query with querySelector
- Wrap it in a try block
A NodeList has forEach but no map;
Play Problem Solving ▸
[...items] or Array.from gives a real array.