School Catalogue Project

Hi, my code is bringing up the following error: /home/ccuser/workspace/learn-javascript-classes-school-catalog/app.js:58
alSmith.sportsTeams();
^
TypeError: alSmith.sportsTeams is not a function

Can someone tell me how to fix this bug?

Here is my code:

1 Like

sportsTeams is a property, not a method. To access a property, use the appropiate syntax:

objectName.propertyName
2 Likes

Fixed it with - console.log(alSmith.sportsTeams); instead of alSmith.sportsTeams(); on the last line

do you understand the difference?

What’s the difference?

the difference between accessing a property (objectName.propertyName) and a method (objectName.methodName()).

getters and setters are just there to change the behavior of getting or setting a property.

1 Like