You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At 22:24 in the video Dan tries to use his constants as the keys in the object but it doesn't work for him. This is because he did it wrong.
when he did it you ended up with an object that had the strings "UP", "DOWN", etc as the keys but you wanted it to be the numbers that those constants represented. The way that you do that is to put the variables in square brackets. For example.
At 22:24 in the video Dan tries to use his constants as the keys in the object but it doesn't work for him. This is because he did it wrong.
when he did it you ended up with an object that had the strings "UP", "DOWN", etc as the keys but you wanted it to be the numbers that those constants represented. The way that you do that is to put the variables in square brackets. For example.
and here's an interactive example https://editor.p5js.org/D_Snyder/sketches/r7rHl0QuA
The term for this is Computed Property Names and more details can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#computed_property_names
The text was updated successfully, but these errors were encountered: