Tell us what’s happening:
Here is what the instructions say:
Now assign the textContent of the showHideCartSpan variable the result of a ternary expression which checks if isCartShowing is true. If it is, set the textContent to “Hide”, otherwise set it to “Show”.
The console log says " You should use ternary syntax to check if “isCartShowing” is true. You should set the “textContent” of the “showHideCartSpan” variable to “Hide” if “isCartShowing” is true. You should set the “textContent” of the “showHideCartSpan” variable to “Show” if “isCartShowing”
is false.
I think that’s what I’m doing. What am I doing wrong?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
cartBtn.addEventListener("click", () => {
isCartShowing = !isCartShowing;
showHideCartSpan.textContent = (isCartShowing) ? "Hide" : "Show";
});
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Challenge Information:
Learn Basic OOP by Building a Shopping Cart - Step 39