Demo: A notebook object
A notebook object
A field notebook tracks its own page count. Its pages property holds state; addPages changes that state with this.pages. Run it and compare the two lines.
javascript
const notebook = {
label: "Field notes",
pages: 4,
addPages(count) { this.pages += count; }
};
console.log(`${notebook.label}: ${notebook.pages}`);
notebook.addPages(3);
console.log(`${notebook.label}: ${notebook.pages}`);
What to notice
Try changing 3 to 1. Next, create a car with its own data and method.