class LightFn{ async run(){ while(true){ console.log(‘this is green 3000‘); await this.sleep(3000); console.log(‘this is yellow 1000‘); await this.sleep(1000); console.log(‘this is red 2000‘); await this.sleep(2000); } } sleep(duration){ return new Promise((resolve, reject)=>{ setTimeout(resolve ,duration); }) } } let a = new LightFn(); a.run();