Tell us what’s happening:
For the project below I figured it out but it took a while because IMO it is badly worded question. I followed the link “get help” and saw a few post were people were saying how to solve it (which I’d already done). I just wanted to add my 2 cents and provide some feedback by saying how the task should have been worded correctly. But because I’m a new forum user I don’t have permissions. So, how exactly am I meant to provide feedback??
As you can see I answered it correctly below but this bit I am on about this statement:
Use the
playerNumber
variable to look up player16
intestObj
using bracket notation. Then assign that name to theplayer
variable.
There are two variables and two statement. It is clearly implied in the first statement (which refers to the first variable) that you have to somehow get the number 16 from the testobj object; it even says to use bracket notation to get it. Then once you have that, you tare then to assign it to the next variable. The statements are incorrect. The first task is as simple as assigning a number. The manipulation of the testobj object has to be done in the second variable therefore the statement should reflect this. In short, the bit about “bracket notation” in the first statement should not be there, it should be in the second statement. I figured it out in the end when I realized the statements were incorrect and you had to use the bracket notation method on the second variable NOT the first variable (which the guide says). I would recommend they fix this up to be clearer.
Your code 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[playerNumber]; // Change this Line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
.
Challenge: Accessing Object Properties with Variables
Link to the challenge: