我是编程的新手,我想知道如何在编写程序时创建机器人!Random回答了我在想,两分钟后他回答了Hello,Hi,Welcome之间的随机响应。 谢谢大家 我不需要完整的代码,但可能需要一些建议
答案 0 :(得分:0)
// Creating an array with answers.
const Answers = ["RandomAnswer1", "RandomAnswer2", "RandomAnswer3", "RandomAnswer4"];
// Picking a random answer every 1 second and logging it.
setInterval(() => {
console.log(Answers[Math.floor(Math.random() * Answers.length)]);
}, 1000);