Message from JavaScript discussions

April 2019

— I feel like something it’s not all right. Could you please send a file or something with all the code?

Message permanent page


Let time = null;
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 time}, 1000)
return time
return clearInterval(this.interval)

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

const test2 = () => console.log(time)

— I'm not an expert but I know I got what I needed

— Ticking should probably just be tick

— Ok, if this is what you need and works for you it’s fine. But imagine having multiple instances of Game. And I think this is not a OOP pattern like you said you wanted.

Message permanent page

— Yeah naming functions and methods is causing me a real headache

— Just make them verbs

— DisplayTime -> getTime

— Could you change this code the way you feel it would be more OOP and paste it here?

— OOP is not a good goal imo

— I was trying to get to this result for six hours, so understand my euphoria 😅

— Display is technically a verb so there so I'm just missing knowledge of common names for variables and functions

Message permanent page