goobric
February 16, 2024, 6:17am
1
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.
You should remove the parentheses around the assignment.
Happy coding!
goobric
February 16, 2024, 8:45am
3
hi Femincan, thank you so much for you advice. Are you able to explain to me why the parentheses need to be removed?
ILM
February 16, 2024, 8:47am
4
the tests don’t account for their presence, so it fails.
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.