Why does my this.pPos is set to a string containing the function code, instead of the function return value?
function game(mode, boardDim) {
//mod
this.mode = mode;
//dim tabla
this.boardDim = boardDim;
//pozitii initiale elemente
if (this.mode == 'easy') {
//creez pozitii specifice
this.pPos = function () {
var pPos = Math.floor(Math.random() * Math.pow(this.boardDim, 2));
return pPos;
};
}
}
var asd = new game('easy');
alert(asd.pPos);
This should return a random number, but it returns the function's text.
asd.pPos()