FreeCodeCampChina / FreeCodeCampChina/freecodecamp.cn

你应该使用括号访问 testObj

Open
#600 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
CSS
Stars
37.8k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

Challenge [Accessing Objects Properties with Variables](https://www.freecodecamp.cn/challenges/accessing-objects-properties-with-variables#?solution=%2F%2F%20%E5%88%9D%E5%A7%8B%E5%8C%96%E5%8F%98%E9%87%8F%0Avar%20testObj%20%3D%20%7B%0A%20%2012%3A%20%22Namath%22%2C%0A%20%2016%3A%20%22Montana%22%2C%0A%20%2019%3A%20%22Unitas%22%0A%7D%3B%0A%0A%2F%2F%20%E8%AF%B7%E5%8F%AA%E4%BF%AE%E6%94%B9%E8%BF%99%E6%9D%A1%E6%B3%A8%E9%87%8A%E4%BB%A5%E4%B8%8B%E7%9A%84%E4%BB%A3%E7%A0%81%0A%0Avar%20playerNumber%3D16%3B%20%20%20%20%20%20%20%2F%2F%20%E4%BF%AE%E6%94%B9%E8%BF%99%E4%B8%80%E8%A1%8C%0Avar%20player%20%3D%20testObj%5B16%5D%3B%20%20%20%2F%2F%20%E4%BF%AE%E6%94%B9%E8%BF%99%E4%B8%80%E8%A1%8C%0A) has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:
```javascript
// 初始化变量
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// 请只修改这条注释以下的代码

var playerNumber=16; // 修改这一行
var player = testObj[16]; // 修改这一行

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.