FreeCodeCampChina / FreeCodeCampChina/freecodecamp.cn

222 Record Collection 修改了全局变量不return不让过

Open
#129 6 comments 0 reactions 0 assignees View on GitHub
enhancement Need Server Update PR Ready
Dominant language
CSS
Stars
37.8k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

题目:222
题目名称:[Record Collection](https://www.freecodecamp.cn/challenges/record-collection)
使用代码:
```JS
function update(id, prop, value) {

if(value=="")
{
delete collection[id][prop];
}
else
{
if(prop=="tracks")
{
collection[id][prop].push(value);
}
else if(prop=="artist")
{
collection[id][prop]=value;
}
}
}
```
问题描述:
使用update函数修改对象

```JS
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
```
使用了上边的代码修改了这个全局的对象以后,检测不通过,经过测试,使用了update对象后,全局变量会自动修改,完全达到了要求,但是不return不允许通过,这样的学习会把对js的理念搞混,未来写代码的时候会认为所有代码都必须要return才可以使用,混乱了人们对全局变量的概念,建议修改。

Contributor guide

Open the contributing guide

Research direction

Start with the Record Collection challenge linked in the issue and reproduce the supplied update function against the provided collection object. Review how the challenge checks the result and decide whether the expected behavior or the lesson guidance needs clarification; done means the agreed behavior is consistently accepted and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
content, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.