I have made the following object in javascript :
var gr = {
SIZE : 30,
NO_X : (window.innerWidth / this.SIZE),
NO_Y : (window.innerHeight / this.SIZE),
drawGrid : function(){
console.log(`NO_X : ${this.NO_X}`);
console.log(`NO_Y : ${this.NO_Y}`);
//
//grid drawing function here
//
}
}
when I call the drawGrid function, the console log statements return the values of both NO_X and NO_Y as NaN, I would like them to equal the screen width / SIZE .
If I use window.innerWidth outside of the object it works as expected.
Sorry if the answer is obvious I am pretty new to programming in javascript.
thanks!