I’m having trouble figuring this out. Can you let me know what the answer is? Thank you. Here is what I have so far:
// Setup
var testObj = {
12: “Namath”,
16: “Montana”,
19: “Unitas”
};
// Only change code below this line;
var playerNumber = [“16”}; // Change this Line
var player = testObj[“Montana”]; // Change this Line
The keys are ints, so you access the data without quotes
var playerNumber = testObj[16]; // Change this Line
In order to use this syntax
var playerNumber =testObj["Montana"];
your code would be like this
var testObj = {
"Namath": 12,
"Montana":16,
"Unitas":19
};
I tried that and it doesn’t pass either. Can you write it out completely the way it’s supposed to look?
1 Like
Nevermind, I got the solution myself. Here it is:
// Setup
var testObj = {
12: “Namath”,
16: “Montana”,
19: “Unitas”
};
// Only change code below this line;
var playerNumber = 16; // Change this Line
var player = testObj[playerNumber]; // Change this Line
2 Likes