Open shfshanyue opened 3 months ago
function LazyMan(name) {
console.log(`Hi! This is ${name}!`);
}
LazyMan.prototype.sleep = function(time) {
const timeInMiliSec = time * 1000;
const start = performance.now();
console.log(`Wait for ${time} seconds...`);
while (performance.now() - start <= timeInMiliSec) {}
console.log(`Wake up after ${time} seconds.`);
return this;
}
LazyMan.prototype.sleepFirst = function(time) {
return this.sleep(time);
}
LazyMan.prototype.eat = function(thing) {
console.log(`Eat ${thing}~~`);
return this;
}