Why do I get this error with this code: Uncaught SyntaxError: Unexpected token { on line 1.
var cube_points = {
{'x' : 100, 'y' : 100, 'z' : 100},
{'x' : 100, 'y' : 100, 'z' : -100},
{'x' : -100, 'y' : 100, 'z' : -100},
{'x' : -100, 'y' : 100, 'z' : 100},
{'x' : 100, 'y' : -100, 'z' : 100},
{'x' : 100, 'y' : -100, 'z' : -100},
{'x' : -100, 'y' : -100, 'z' : -100},
{'x' : -100, 'y' : -100, 'z' : 100}
};
Your outer object’s elements have values but no keys. If you want an array of cube points, use the square bracket to denote an array literal:
If you want an object, give the items a key. This could be numbers or letters or even objects:
Obviously, using an object necessitates some kind of orderly system of key selection. Since your points aren’t easily named, you’re better off using an array. But I wanted to show what object literal notation would look like.