[英]why is console.log not working with this code(i am not console.log (ging) infinitely)
这是一个简单的 cli(控制台行界面)待办事项应用程序的代码,但是当这个代码运行时,console.log 不起作用我只在 chrome 中尝试过
let todos = [];
let user_input = 0;
while (user_input !== "quit") {
user_input = prompt("what would you like to do?");
if (user_input === "new") {
todos.push(prompt("what will be the todo"));
console.log("bruh");
} else if (user_input === "list") {
for (let i = 0; i <= todos.length - 1; i++) {
console.log(`${i + 1}: ${todos[i]}`);
}
} else if (user_input === "delete") {
let index = parseInt(
prompt("what is the index of item you want to delete")
);
todos.splice(index, 1);
for (let i = 0; i <= todos.length - 1; i++) {
console.log(`${i + 1}: ${todos[i]}`);
}
}
}
console.log("thanks for using me");
我是初学者对不起,如果这是愚蠢的问题提前谢谢
您只需将“while”更改为“if”即可:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.