gpt4 book ai didi

javascript - 如何拥有多个 'and' 逻辑运算符和一个 'or' 逻辑运算符

转载 作者:行者123 更新时间:2023-12-02 18:44:50 24 4
gpt4 key购买 nike

这有点难以解释,但我想做一些看起来像这样的事情:

if(a === 4 && b === true && c === "words" || "numbersandwords")DoSomething();

但它结束运行时没有匹配第一个运算符。我想知道如何让最后一个运算符除了 2 个不同的输入之外,同时仍然确保在运行之前满足其他条件。

最佳答案

您只需要使用括号,例如:

if(a == 4 && b == true && (c == "words" || c == "numbersandwords")) { DoSomething(); }

关于javascript - 如何拥有多个 'and' 逻辑运算符和一个 'or' 逻辑运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16513124/

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