I am new to JS. I am learning JS OOP's concepts. I am trying to use constructor to create private variables in JS. But when I try to access the values using getters, I get an error 'TypeError: 'undefined' is not a function '
function Card(n,s) {
var number = n;
var suit = s;
//getters
var getNumber = function(){
return this.number;
};
var getSuit = function(){
return this.suit;
};
}
var test = new Card(10, 1);
test.getNumber();
I am not able to figure out what the error might be. Need some help on this.