期望的输出: -
错误:您已断开连接!
警告:你已闲置15分钟
// Code starts here
// Do not edit this function
function output(msg) {
console.log(this.type, ":", msg)
}
// You may edit below this line not including the .output functions.
var errorMsg = ;
var warningMsg = ;
// Do not edit below this line.
errorMsg.output('You have been disconnected!');
warningMsg.output('You have been idle for 15 minutes');
答案 0 :(得分:1)
您可以使用函数作为errorMsg
和warningMsg
的构造函数,如下所示:
var Logger = function(type) {
this.type = type
this.output = output
}
var errorMsg = new Logger('warning');
var warningMsg = new Logger('error');
这是working plunker 如果您还有其他问题,请随时提出。
答案 1 :(得分:0)
我不确定你是否在寻找这个:
gunicorn