Skip to content
Advertisement

Accessors not printing out the correct output

I’m trying to get my program to print each of the 4 variables (wholeNumber, decimalPart, positive, currencySymbol) defined in the program below using an accessor for each, however when I go to run the program instead of getting this

Expected Output:

JavaScript

I instead get this. Could someone explain what error is causing this?

CURRENT OUTPUT

CODE

JavaScript

Advertisement

Answer

You forgot to set the member variables in the constructor, so they are left at their default values.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement