0

This should be simply but I cant figure it out, all I'm trying to do is add an or condition to my ternary operator, heres the code:

{cat === 'electronics' || 'jewelery' ? '' : <Size><b>Size: </b>{size}</Size>}

There are 4 categories 2 can have size these 2 cant, now if I remove the or condition like so:

{cat === 'jewelery' ? '' : <Size><b>Size: </b>{size}</Size>}

This work perfectly fine but then I'll have to add another test when I dont see why || shouldnt be working.

any help is appreciated.

SlugLord
  • 143
  • 1
  • 9
  • 1
    The way you've written it the second string is being tested for truthiness not equality, you need to explicitly write out all comparisons. `cat === 'electronics' || cat === 'jewelery' ? '' : ...` – pilchard Sep 28 '21 at 18:10
  • try like this, `{(cat === 'electronics' || cat === 'jewelery') ? '' : Size: {size}}` – Dev-2019 Sep 28 '21 at 18:16
  • 1
    Thank you both, I'd mark either one of these answers as correct but for some reason the questions been linked to an irrelevant one. – SlugLord Sep 28 '21 at 18:36

0 Answers0