var table = document.querySelectorAll(".numbers");
function seppuku() {
for (let i in table) {
table[i].style.color = "red";
}
}
seppuku();
<div class="numbers">1</div>
<div class="numbers">2</div>
<div class="numbers">3</div>
So here's my code. My problem is: Why console.log communicate "Cannot set property 'color' of undefined" after seppuku() function invoking?
It's not like var table is not defined! Actually, it has global scope and should be available for 'for.. in' loop. Moreover, this function works, chosen elements has color: red property now. How that works despite the communicate in console?