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
No active XP Potion
Accept a Quest
Login to submit answers
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
tree
was 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.
Focus Editor
Alt+Shift+]
Next Tab
Alt+Shift+[
Become a member to Submit
Become a member to Run
Become a member to view solution