I have a problem with the method array.some() in JavaScript. I have an html-code:
<div class="list">
<div class="item"></div>
<div class="item"></div>
<div class="item selected"></div>
</div>
And I'm trying to find one element of array which contains class-name "selected".
const items = document.querySelectorAll('.item');
items.some(item => {
if (item.classList.contains('selected')) { console.log(true); }
else { console.log(false); }
});
But all what I get is this error: "Uncaught TypeError: items.some is not a function" Can someone tell me, why the method Array.some() doesn't work for div array? Thank you