* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
1.7 KiB
1.7 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56bbb991ad1ed5201cd392d2 | Add New Properties to a JavaScript Object | 1 | 将新属性添加到JavaScript对象 |
Description
ourDog
添加"bark"
属性: ourDog.bark = "bow-wow";
或者我们的ourDog["bark"] = "bow-wow";
现在当我们评估我们的ourDog.bark
,我们会得到他的吠声,“低头哇”。 Instructions
myDog
添加"bark"
属性并将其设置为狗声,例如“woof”。您可以使用点或括号表示法。 Tests
tests:
- text: 将属性<code>"bark"</code>添加到<code>myDog</code> 。
testString: assert(myDog.bark !== undefined);
- text: 不要在设置部分添加<code>"bark"</code>
testString: assert(!/bark[^\n]:/.test(code));
Challenge Seed
// Example
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};
ourDog.bark = "bow-wow";
// Setup
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
// Only change code below this line.
After Test
console.info('after the test');
Solution
// solution required