Methods with parameters and return values (JavaScript)
A class method takes a parameter (amount) and uses return to give back a value worked out from the object's properties, such as the new balance.
Understanding Methods with parameters and return values (JavaScript) in ACARA Digital Technologies Years 9–10
What it does: extra is the parameter, this.points is the property, and return gives back the calculated total. Inside a class method, the object's properties are reached with this. Plain width and height would be undefined variables. Template literals need backticks. Single quotes treat ${...} as plain text, so the values would not be inserted. A parameter is a placeholder. The value (argument) you put in the brackets when you call the method fills it in. console.log only prints to the console. To use the result elsewhere in your program, the method must return it. The method adds 20 to this.balance, making it 120, then returns this.balance. It returns the new balance, not the amount passed in.
Common mistakes: Inside a method, the object's property must be reached with this. Without this, balance is treated as a separate variable and causes a ReferenceError. It should be this.balance += amount;. A method needs parentheses after its name, even when it takes no parameters. It should be getArea() {.
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.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
deposit(amount) { this.balance += amount; return this.balance; }Fill in the Blanks
Spot the Error
Student with a class code? Join your class →