简体   繁体   中英

Ternary Operator with two conditions

I am currently working on a ternary operator that I want to have 2 conditions. I am having issues with the second condition. I am trying to get it to where If ActionTypeId = 0 OR ActionCompletedByID is greater than 0 display null. If true, return the StatusModal .I believe the way I have it written is in the situation of AND and not OR is there a way to write these conditions as an OR?

 currentNurse.ActionTypeID === 0, currentNurse.ActionCompletedByID > 0? null :
     <StatusModal
      details = {details}>
     </StatusModal>

You could inverse the checks and take logical AND along with the wanted tags - and omit null .

currentNurse.ActionTypeID !== 0 && currentNurse.ActionCompletedByID <= 0 && 
    <StatusModal
      details = {details}>
    </StatusModal>

The way you've written it is neither AND or OR. I don't think what you have is even valid syntax.

What you need to do is use the OR operator.

 currentNurse.ActionTypeID === 0 || currentNurse.ActionCompletedByID > 0? null :
     <StatusModal
      details = {details}>
     </StatusModal>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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