我正在创建一个 Simon Says 游戏,其中随着用户获得正确的模式,模式会逐渐变长,但输入历史显示他们之前的模式输入。如何清除此历史记录?
此代码位于 CodeHS 网站上。我已经研究并尝试过 console.clear();, clear(); 和 console.API.clear();,但它似乎不起作用。
这是我的代码中获取用户输入的部分。
//green red blue yellow
var generatedPattern = "grby"
function getUserInput(){
/*User input of the last round gets saved which shows them 'grb', allowing
the user to look back at their previous guess to easily guess the
next pattern*/
guess = readLine("Input guess here: (example: ybbg)");
if(guess == generatedPattern){
return true;
}else{
return false;
}
}
我希望用 clear() 清除日志;或 console.clear();,但它什么也没做。