← ACARA Digital Technologies Years 9–10

Methods that change an object's properties

A method line that updates the object's own property, so its state changes each time the method is called. Calling deposit(50) twice adds 50 twice.

Understanding Methods that change an object's properties in ACARA Digital Technologies Years 9–10

What it does: The method uses this.balance to reach the object's own property and update it when called. Each call updates this.balance again, so two deposits of 50 add up to 100. The check must come before the change. In the wrong option the balance is already updated before the check runs. The -= operator updates the property itself, so the object's state changes. It does not just calculate a value.

Common mistakes: The closing bracket is missing from the parameter list. It should be deposit(amount) {. Without this., JavaScript looks for a variable called balance, not the object's property. It should be this.balance += amount;.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 728–742) and word search (Modules 710–742).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which method line changes the object's own balance?
this.balance += amount;balance += amount;
Matches
deposit(amount) { balance += amount; }
↓
balance has no this. in front of it, so the method does not update the object's property. It looks for a plain variable and causes an error.
Applying
Meanings
Term
this.balance += amount
Meaning
A method line that updates the object's own property, so its state changes each time the method is called. Calling deposit(50) twice adds 50 twice.
Practice
class Account {
Testing
Gaps
this.balance amount;
Check Answer
Spots
1deposit(amount {
2 this.balance += amount;

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Woodland Hedgehog' badge — Import Master, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which method line changes the object's own balance?
A. this.balance += amount; ✓
B. balance += amount;
this. points to the property on the object. Without it, JavaScript looks for a separate variable called balance and gives an error.
2. After account.deposit(50) runs on an account with balance 100, what is account.balance?
A. 100
B. 150 ✓
The method updates this.balance, so the object's state changes. It stays changed after the method finishes.
3. If you call account.deposit(50) twice on a balance of 100, what is the balance?
A. 200 ✓
B. 150
Each call adds 50 to the stored balance: 100 + 50 + 50 = 200. The state carries over between calls.
4. Which method checks the amount before it changes the balance?
A. if (amount > 0) { this.balance += amount; } ✓
B. this.balance += amount; if (amount > 0) { }
The check must come before the change. In the wrong option the balance is already updated before the check runs.
5. A withdraw method has this line: this.balance -= amount; What does calling it do?
A. It only prints a smaller number and leaves balance alone
B. It lowers the object's balance each time it is called ✓
The -= operator updates the property itself, so the object's state changes. It does not just calculate a value.

Match the Pairs

this.balance += amount; → Adds the amount to the object's own balance property, so the object's state changes
if (amount > 0) { this.balance += amount; } → Checks the amount is valid before changing the property, so bad values leave the state unchanged
A method changes the object's state by updating a property with this → deposit(amount) { this.balance += amount; }
Calling a changing method twice applies the change twice, so the state builds up → acc.deposit(50); acc.deposit(50); // balance is now 100 if it started at 0
deposit(amount) { balance += amount; } → balance has no this. in front of it, so the method does not update the object's property. It looks for a plain variable and causes an error.
deposit(amount) { this.balance + amount; } → The + operator only works out a total and throws it away. It never stores the result, so this.balance does not change.

Key Term

this.balance += amount
A method line that updates the object's own property, so its state changes each time the method is called. Calling deposit(50) twice adds 50 twice.

Fill in the Blanks

1. deposit(amount) { this.balance += amount; }
Hint: Type the operator that adds the amount onto the existing balance.
2. if (amount <= this.balance) { this.balance -= amount; }
Hint: Type the comparison operator that checks the amount is not more than the balance.
3. withdraw(amount) { this.balance -= amount; }
Hint: Type the keyword that refers to the object the method belongs to.
4. account.deposit(50); account.deposit(50); console.log(account.balance);
Hint: Type the property name that holds the object's updated state.
5. if (amount > 0) { this.balance += amount; }
Hint: Type the keyword that starts a check before the property is changed.

Spot the Error

Question 1
A deposit(amount {
B this.balance += amount;
C }
Line A — The closing bracket is missing from the parameter list. It should be deposit(amount) {.
Question 2
A class Account {
B deposit(amount) {
C balance += amount;
D }
E }
Line C — Without this., JavaScript looks for a variable called balance, not the object's property. It should be this.balance += amount;.
Question 3
A const acc = new Account(100);
B acc.deposit(50);
C acc.deposit(50);
D console.log(acc.balance());
Line D — balance is a property, not a method, so it must not be called with (). It should be console.log(acc.balance); and prints 200.
Question 4
A function withdraw(amt) {
B if (this.balance >= amt) {
C this.balance -= amt;
D }
E }
Line A — Methods inside a class are written without the function keyword. It should be withdraw(amt) {.
Question 5
A deposit(amount) {
B if (amount <= 0) return;
C this.balance += amount;
D this.deposits + 1;
E }
Line D — this.deposits + 1 works out a value but never stores it, so the property does not change. It should be this.deposits += 1;.

Student with a class code? Join your class →