user1249220
user1249220

Reputation: 21

Creating a dynamic object in javascript

I'm trying to understand why my code isn't working. this is a piece of code that I'm creating for a game in canvas. I want to dynamically create an object to capture the radius, x and y coordinates. Eventually this will become a setInterval functon If i can get the console.log to produce I'll be good.

var i;
var circles = {};
for (i = 0; i>10; i++){
  circles[i]= {
    d:Math.floor(Math.random()*50),
    x:Math.floor(Math.random()*500),
    y:Math.floor(Math.random()*500)
    };
    console.log(circles[i].d, circles[i].x, circles[i].x);
};

Upvotes: 0

Views: 158

Answers (1)

Dogbert
Dogbert

Reputation: 222118

for (i = 0; i>10; i++){

should be

for (i = 0; i<10; i++){

Upvotes: 4

Related Questions