As a newcomer to Javascript, I have a basic question. I am attempting to create a for loop where new variables are generated based on the value of i. How can I dynamically change variable names using the i value (without resorting to an array)? For instance, in the code snippet below, my aim is to produce top1, top2, left1, left2, and so on.
var i;
for (i=1; i<3; i++) {
var top'i'=Math.random(); top'i'=450*top-150;
var left'i'=Math.random(); left'i'=left*1150;
document.getElementById("image'i'").style.top=top'i'+"px";
document.getElementById("image'i'").style.left=left'i'+"px";
document.getElementById("image'i'").style.display="block";
}