I want to add condition in constructor for angle if(angle>360){ angle=0; } how to do?
PLAYER[i] = {
color: "#fff",
x: 220*i,
y: 270,
width: 32,
height: 32,
angle: 180
};
each time to use such a condition, takes a lot of space.
This isn’t a constructor — just initialization of an object. But nevermind that. Use the ternary operator:
angle: (angle > 360 ? 0 : angle)