How to create objects in an array in javascript -


hi i've been coding game in javascript, first, , i'm trying create objects in array. i've written following code i'm not sure if works properly. can verify or correct this?

for (i=0;i<10;i++){     objs [i] = '"i" = {x=(i*100),y=(i*100)}' } 

thanks

i assume trying put objects in array.

first declare array

var objs = []; 

then like

for (var i=0;i<10;i++){     objs[i] = {x:i*100,y:i*100} } 

you had lot of superflous code in there.

you need learn how figure out if code works. interpreter chokes on example written. can open web tools, paste code in, , run it, start figuring out errors.

here fiddle might you.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -