

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Objects
incomplete
2: No Colon
incomplete
3: Updating Properties
incomplete
4: Nesting Properties
incomplete
5: Nesting Properties Quiz
incomplete
6: Optional Chaining
incomplete
7: When to Chain
incomplete
8: Object Methods
incomplete
9: Methods Mutate
incomplete
10: Initializing Props
incomplete
11: Strings As Keys
incomplete
12: This
incomplete
13: Arrow Functions
incomplete
14: Fat Arrows and This
incomplete
15: Spread Syntax
incomplete
16: Return Objects
incomplete
17: Destructuring
incomplete
18: Not Bound
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Methods can change the properties of their objects as well:
const tree = {
height: 256,
color: "green",
cut() {
this.height /= 2;
},
};
tree.cut();
console.log(tree.height);
// prints 128
tree.cut();
console.log(tree.height);
// prints 64
You might be wondering:
Wait... I thought
treewas a constant?!?
You're right, but in JavaScript, the const keyword doesn't stop you from changing the properties of an object... it only stops you from reassigning the variable (tree in this case) to a new object. Do not trust const objects to have constant contents!
Complete the sendMessage() method on the campaign object. For now, it should simply increment the campaign's sentMessages counter by 1.