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.
1 Like
You should remove the parentheses around the assignment.
Happy coding!
2 Likes
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?
1 Like
ILM
February 16, 2024, 8:47am
4
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
system
Closed
December 20, 2024, 9:18pm
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.