【发布时间】:2021-03-06 12:49:03
【问题描述】:
这是一个简单的 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");
我是初学者 对不起,如果这是个愚蠢的问题 提前谢谢
【问题讨论】:
-
在 Firefox 和 Chrome 中为我工作。您究竟是如何尝试使用该代码的?
-
@pointy 你能看到console.log吗?
-
@Pointy while 循环中的每个 console.log 都不会显示在控制台中
-
打开你的控制台并输入
console.log("hello world")。这行得通吗?