“`”

参考回答:

<pre><code>function Hero(name){
let o=new Object();
o.name=name;
o.time=0;
console.log(""Hi! This is ""+o.name);
o.kill=function(bugs) {
if(bugs==1){
console.log(""Kill ""+(bugs)+"" bug"");
}else {
setTimeout(function () {
console.log(""Kill "" + (bugs) + "" bugs"");
}, 1000 * this.time);
}
return o;
};
o.recover=function (bloods) {
console.log(""Recover ""+(bloods)+"" bloods"");
return o;
}
o.sleep=function (sleepTime) {
o.time=sleepTime;
return o;
}
return o;
}
</code></pre>

 

<pre><code> "“`

Was this helpful?

0 / 0

发表回复 0

Your email address will not be published.