React - ternary operator for variable (and with backtick)

0 votes
609 views
added Apr 21, 2021 in React by lcjr First Warrant Officer (11,790 points)
edited Apr 21, 2021 by lcjr
const isDefender = modelItemData.uid_i !== 110 ? false : true;
const isBronco = isFord && isTough ? true : false;
const isGwagen = authContext.carData.uid == 1979 ? true : false;
const isJeep  = listingItemData.field_exclusive_i === 1 ? true : false; 

 

1 Response

0 votes
responded Apr 21, 2021 by lcjr First Warrant Officer (11,790 points)
edited Apr 27, 2021 by lcjr
const ph = agentContact.charAt(0) == 6 ? agentContact : `6${agentContact}`;
const fullURL = `https://example.com/listing/${listingItemData.url_s}`;
const finalGallery = doesImagesExist ? gallery : noImg;

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...