Uncaught TypeError: Cannot read property 'classList' of undefined
<p>I'm trying to do simple slider for my site on js, but i have problem. </p>

<p>I have variable "i", and i can't use it.</p>

<p>You can see at my code.</p>

<p>What is solution of this problem?</p>

<pre><code>    var slider = [];
    var radio = [];

for (var i = 1; document.querySelector('.radio-' + i) !== null; i++) { //this variable

radio[i] = document.querySelector('.radio-' + i);
radio[i].addEventListener('click', function () {
    for (var u = 1; document.querySelector('.slider' + u) !== null; u++) {
        slider[u] = document.querySelector('.slider' + u);

        if (slider[u].classList.contains('slider-show')) {
            slider[u].classList.remove('slider-show');
        }
    }
    slider[i].classList.add('slider-show'); //want to use here
});
}
</code></pre>