Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

React - ternary operator for variable (and with backtick)

0 votes
135 views
added Apr 21 in React by lcjr Second Warrant Officer (6,120 points)
edited Apr 21 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 by lcjr Second Warrant Officer (6,120 points)
edited Apr 27 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.
...