* fix: remove example code from challenge seed * fix: remove declaration from solution * fix: added sum variable back in * fix: reverted description back to original version * fix: added examples to description section * fix: added complete sentence Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: corrected typo Co-Authored-By: Manish Giri <manish.giri.me@gmail.com> * fix: reverted to original desc with formatted code * fix: removed unnecessary code example from description section Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: failiing test on iterate through array with for loop * fix: changed to Only change this line Co-Authored-By: Manish Giri <manish.giri.me@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Manish Giri <manish.giri.me@gmail.com> Co-authored-by: moT01 <tmondloch01@gmail.com>
1.9 KiB
1.9 KiB
id, title, challengeType, videoUrl, forumTopicId
id | title | challengeType | videoUrl | forumTopicId |
---|---|---|---|---|
56bbb991ad1ed5201cd392d1 | Updating Object Properties | 1 | https://scrimba.com/c/c9yEJT4 | 18336 |
Description
ourDog
:
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};
Since he's a particularly happy dog, let's change his name to "Happy Camper". Here's how we update his object's name property:
ourDog.name = "Happy Camper";
or
ourDog["name"] = "Happy Camper";
Now when we evaluate ourDog.name
, instead of getting "Camper", we'll get his new name, "Happy Camper".
Instructions
myDog
object's name property. Let's change her name from "Coder" to "Happy Coder". You can use either dot or bracket notation.
Tests
tests:
- text: You should update <code>myDog</code>'s <code>"name"</code> property to equal "Happy Coder".
testString: assert(/happy coder/gi.test(myDog.name));
- text: You should not edit the <code>myDog</code> definition.
testString: 'assert(/"name": "Coder"/.test(code));'
Challenge Seed
// Setup
var myDog = {
"name": "Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
// Only change code below this line
After Test
(function(z){return z;})(myDog);
Solution
var myDog = {
"name": "Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
myDog.name = "Happy Coder";