2018-09-30 22:01:58 +00:00
---
id: 56bbb991ad1ed5201cd392d1
title: Updating Object Properties
challengeType: 1
2019-02-14 17:24:02 +00:00
videoUrl: 'https://scrimba.com/c/c9yEJT4'
2019-07-31 18:32:23 +00:00
forumTopicId: 18336
2021-01-13 02:31:00 +00:00
dashedName: updating-object-properties
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2018-09-30 22:01:58 +00:00
After you've created a JavaScript object, you can update its properties at any time just like you would update any other variable. You can use either dot or bracket notation to update.
2020-11-27 18:02:05 +00:00
For example, let's look at `ourDog` :
2019-05-17 13:20:30 +00:00
```js
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};
```
2021-03-03 00:12:12 +00:00
Since he's a particularly happy dog, let's change his name to the string `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` .
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --instructions--
2018-09-30 22:01:58 +00:00
2021-03-03 00:12:12 +00:00
Update the `myDog` object's name property. Let's change her name from `Coder` to `Happy Coder` . You can use either dot or bracket notation.
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --hints--
2018-09-30 22:01:58 +00:00
2021-03-03 00:12:12 +00:00
You should update `myDog` 's `name` property to equal the string `Happy Coder` .
2020-11-27 18:02:05 +00:00
```js
assert(/happy coder/gi.test(myDog.name));
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
You should not edit the `myDog` definition.
```js
assert(/"name": "Coder"/.test(code));
```
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --after-user-code--
```js
(function(z){return z;})(myDog);
```
## --seed-contents--
2018-09-30 22:01:58 +00:00
```js
// Setup
var myDog = {
"name": "Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
2020-03-03 07:18:30 +00:00
// Only change code below this line
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
```js
var myDog = {
"name": "Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
myDog.name = "Happy Coder";
```