* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.2 KiB
1.2 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56bbb991ad1ed5201cd392d2 | 给对象添加新属性 | 1 | https://scrimba.com/c/cQe38UD | 301169 | add-new-properties-to-a-javascript-object |
--description--
你也可以像更改属性一样给对象添加属性。
看看我们是如何给ourDog
添加"bark"
属性:
ourDog.bark = "bow-wow";
或者
ourDog["bark"] = "bow-wow";
现在当我们访问ourDog.bark
时会得到 ourDog 的 bark 值 "bow-wow".
--instructions--
给myDog
添加一个"bark"
属性,设置它的值为狗的声音,例如:"woof"。你可以使用点或中括号操作符。
--hints--
给myDog
添加"bark"
属性。
assert(myDog.bark !== undefined);
不能在初始化 myDog 的时候添加"bark"
属性。
assert(!/bark[^\n]:/.test(code));
--seed--
--after-user-code--
(function(z){return z;})(myDog);
--seed-contents--
// Setup
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
// Only change code below this line
--solutions--
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
myDog.bark = "Woof Woof";