Learn Basic OOP by Building a Shopping Cart - Step 51

Tell us what’s happening:

I’m getting this prompt " You should use template literal syntax to add the dollar sign before your .toFixed() call."

I don’t really understand how to add the template literal here.

Your code so far

calculateTotal() {
const subTotal = this.items.reduce((total, item) => total + item.price, 0);
const tax = this.calculateTaxes(subTotal);
this.total = subTotal + tax;
cartSubTotal.textContent = $${subTotal.toFixed(2)};
cartTaxes.textContent = $${this.tax.toFixed(2)};
cartTotal.textContent = $${total.toFixed(2)};
}

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.15

Challenge Information:

Learn Basic OOP by Building a Shopping Cart - Step 51

To sum this up in short your need two backticks ``

would I put them inside the template literal I already have for that variable?

What do you mean the by the variable you already have?

ah I didn’t mean variable

But I already have backticks

cartTaxes.textContent = $${this.tax.toFixed(2)};

so would I add more on the inside?

Ok it appears the only thing your missing is wrapping that code with the ``
but just the assignment side.

Like this?

cartTaxes.textContent = $${this.tax.toFixed(2)};

for some reason it is not showing up on the thread but I have a backtick before the first $ and after the last }

ah that worked. I had the “this” on the wrong line. Thank you!

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

you can use the code tool to post code in the forum. That will post your full answer with backticks

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

I did twice. can you tell me if I should be using a spoiler?

in this particular instance a spoiler isn’t necessary.

The OP was super close to the right answer.
It would have been better say, “remove the this keyword from this line and add it to this line” to pass.

spoilers should only be used if you are sharing a full answer and hoping to get feedback on how it works or clarifications on how it works.

sometimes, people will use it for posting about the certification projects and they are looking to get feedback on their solutions.

Yes I agree, so this was a matter of the this keyword?

yeah, that was the issue.
the this keyword was being used on the wrong line

1 Like

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