Learn Basic OOP by Building a Shopping Cart - Step 39

Tell us what’s happening:

I’m stuck on finding a way to tell the “truthiness” of isCartShowing.

I already ran into That Post (perfect to rethink about my code, and how to think the ternary operator)

I know I’m being confused by the fact that I needed to invert the value of isCartShowing before. Furthermore, I tried to check is isCartShowing had just any values, but it doesn’t work…

Your code so far

cartBtn.addEventListener("click", () => {
  isCartShowing = !isCartShowing;
  isCartShowing =  showHideCartSpan 
   ? showHideCartSpan.textContent="Hide" 
   : showHideCartSpan.textContent="Show";
});

Thanks for any advice in advance

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 39

cartBtn.addEventListener(“click”, () => {
isCartShowing = !isCartShowing;
showHideCartSpan.textContent = isCartShowing ? “Hide” : “Show”;
});

Basically you check if the value of the element is true.

what value should isCartShowing have? becuase first you assign it a boolean then a string

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.