Message from JavaScript discussions

April 2019

— Guys I have a question


If I want to update a variable I first declare it and later when I call a function I can update it's value, I tried to do the same with an object made from contractor and it didn't work

— admin ban

— Show code

— After declaring that new object I called a method and the method changed the variable internally but it didn't update that object

Message permanent page

— Right away...

— Class Game {
constructor(pace, money){
this.hour = (a) =>{
a = Math.floor(this.startTime/60)
return (a > 23) ?a = 0 :a
this.minute = (a) => {
a = this.startTime%60
return (a < 10) ?'0'+a :a }
this.startTime = 464;
this.pace = pace; = money; //12
this.interval = null;
this.process = null;
return this.hour() +':'+this.minute()
return this.startTime++
this.interval = setInterval(()=>{
return this.startTime}, 1000)
return clearInterval(this.interval)


const newGame = new Game(1000, 10000);
const test =()=>newGame.pause()
setTimeout(test, 8000)

Message permanent page

— This code generates a fake time and when you call it shows everything well

— But when you check the new game.startTime it doesn't update

— So what do you think?

— Or is it impossible to change a value of an object's property by calling the same object's method??

— There are 1100 coders in this group and nobody can help