0

I am trying to declare multiple variables in a for loop but the way I am doing it its not working, I tried to search for similar questions but couldnt find...

 for (var n = 0;  n < 10; n++) 
   {  
        var b + n = document.getElementById("b" + n);               
   }

1 Answers1

2

Try to use the Array

var b = new Array();
for (var n = 0;  n < 10; n++) 
{  
    b[n] = document.getElementById("b" + n);               
}
Alex S.
  • 622
  • 4
  • 6