【问题标题】:Ternary if Condition三元 if 条件
【发布时间】:2022-08-10 15:37:48
【问题描述】:

我有这个 if 条件,在三元条件下这个等价物是什么?

if(status === \'Active\'){
    return Active
}
if(status === \'InActive\'){
   return InActive
}
else{
   return Suspended
}

标签: javascript


【解决方案1】:

return (status === 'Active' ? Active : (status === 'InActive' ? InActive : Suspended))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-08
    • 2022-12-06
    • 2019-01-24
    • 2017-08-26
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 2016-03-30
    相关资源
    最近更新 更多