2 Java 脚本中的比较 - Telegram Bot
2 Comparison in Java Script - Telegram Bot
如何在此代码中使用 or 进行 2 比较?
//not work
if (msg.text != "/start" || msg.text != "Contact us") {
keyboard.push(["Main Menu","Back"]);
}
return keyboard;
}
刚开始工作时
if (msg.text != "/start") {
keyboard.push(["Main Menu","Back"]);
}
return keyboard;
}
来自我最初的评论:
Maybe you want to use the AND operator for that, as your condition will always be true. msg.text
cannot both be "/start"
and "Contact us"
at the same time.
通过将 ||
替换为 &&
,如果 msg.text
不是两个字符串中的任何一个,则您的条件将为真。
如何在此代码中使用 or 进行 2 比较?
//not work
if (msg.text != "/start" || msg.text != "Contact us") {
keyboard.push(["Main Menu","Back"]);
}
return keyboard;
}
刚开始工作时
if (msg.text != "/start") {
keyboard.push(["Main Menu","Back"]);
}
return keyboard;
}
来自我最初的评论:
Maybe you want to use the AND operator for that, as your condition will always be true.
msg.text
cannot both be"/start"
and"Contact us"
at the same time.
通过将 ||
替换为 &&
,如果 msg.text
不是两个字符串中的任何一个,则您的条件将为真。