I am assigning random values between 1-50 to object elements, I have 5 objects, I don't know why but all the objects are getting the same random values...
here is my code :
var SmileyRed = {
radius: 15,
xspeed: 0,
yspeed: 0,
xpos:350, // x-position of smiley
ypos: 65 // y-position of smiley
};
var SmileyReds = new Array();
for (var i=0; i<5; i++){
SmileyReds[i] = SmileyRed;
SmileyReds[i].xspeed = Math.floor((Math.random()*50)+1);
SmileyReds[i].yspeed = Math.floor((Math.random()*50)+1);
}
SmileyReds[0].xspeed and SmileyReds[3].xspeed have the same values but shouldn't they be different?