gpt4 book ai didi

javascript - 为什么没有任何内容记录到控制台? {JavaScript}

转载 作者:行者123 更新时间:2023-11-30 10:25:09 26 4
gpt4 key购买 nike

这是一个判断 minecraft 服务器论坛版主应用程序的程序。我想知道为什么除了默认值什么都没有输出。请帮助我。

代码在这里:

     var moderatorApplicant=new Object();
moderatorApplicant.active=true; //boolean;
moderatorApplicant.age=15; //number;
moderatorApplicant.applicationLength="long"; //string, "short" or "long";
console.log("Moderator Application Judge Result:");
switch(moderatorApplicant)
{
case (moderatorApplicant.active===true&&moderatorApplicant.age>=14&&moderatorApplicant.applicationLength=="long"):
console.log("You are fit for a mod! +1");
break;
case (moderatorApplicant.active===true&&moderatorApplicant.age<14&&moderatorApplicant.applicationLength=="long"):
console.log("You're active! You're app is long! You aren't 14 or over though, so +0.");
break;
case (moderatorApplicant.active===true&&moderatorApplicant.age>=14&&moderatorApplicant.applicationLength=="short"):
console.log("App is short, but you're active, and you meet age requirements. +0");
break;
case (moderatorApplicant.active===true&&moderatorApplicant.age<14&&moderatorApplicant.applicationLength=="short"):
console.log("You're active, your app is short, and you are younger than 14. -1");
break;
case (moderatorApplicant.active===false&&moderatorApplicant.age>=14&&moderatorApplicant.applicationLength=="long"):
console.log("You are not active, but you are over 14 and have a long app. Try again when you are more active +0");
break;
case (moderatorApplicant.active===false&&moderatorApplicant.age<14&&moderatorApplicant.applicationLength=="long"):
console.log("You're young, you aren't active, but your app is long. -1");
break;
case (moderatorApplicant.active===false&&moderatorApplicant.age>=14&&moderatorApplicant.applicationLength=="short"):
console.log("You are not active. You made a short app, but you are over 14. -1");
break;
case (moderatorApplicant.active===false&&moderatorApplicant.age<14&&moderatorApplicant.applicationLength=="short"):
console.log("This is the definition of a bad application. Not active, younger than 14, and short app. -1.");
break;
default:
console.log("Check again. Inappropriate values.");
break;
}

最佳答案

在 JavaScript 中,switch statements期望一个常量值(文字数字或字符串)。您应该使用 if/else 语句以便能够在每种情况下使用表达式。

关于javascript - 为什么没有任何内容记录到控制台? {JavaScript},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19945100/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com