繁体   English   中英

为什么console.log不能使用这个代码(我不是console.log(ging)无限)

[英]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");

我是初学者对不起,如果这是愚蠢的问题提前谢谢

Go 到开发人员工具中的控制台选项卡,并检查是否在标签下拉菜单下选择了信息

在此处输入图像描述

您只需将“while”更改为“if”即可:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM