Basic JavaScript: Accessing Object Properties with Variables | freeCodeCamp.org

EMBED

Tue Sep 27 2022 13:50:29 GMT+0000 (Coordinated Universal Time)

Saved by @chymax030 #javascript


// Setup const testObj = { 12: "Namath", 16: "Montana", 19: "Unitas" }; // Only change code below this line const playerNumber = 16; // Change this Line const player = testObj[playerNumber]; // Change this Line

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-variables