Learn-basic-oop-by-building-a-shopping-cart - Step 28

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-basic-oop-by-building-a-shopping-cart/step-28
Current Code

currentProductCount > 1 ? (currentProductCountSpan.textContent = `${currentProductCount}x`) : undefined;

fCC test error message “You should use template literal syntax to update the textContent to be ${currentProductCount}x.”
Can someone at fCC please explain the error message given; and where a template literal has not been used in my code.
Thank you.

1 Like

You should remove the parentheses around the assignment.

Happy coding!

2 Likes

hi Femincan, thank you so much for you advice. Are you able to explain to me why the parentheses need to be removed?

1 Like

the tests don’t account for their presence, so it fails.

2 Likes

I did not even know that you could assign a value to a variable within a ternary conditional statement.

I was trying to assign both the truthy or falsy statements to the required property, like this, but it was not working:

object.property = condition ? true : false

Thank you for posting this.

1 Like

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