Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Getting Started With ES2015 Using Template Literals Review Template Literals

backtick key on mac

I am inputting this code to the console, but it won't take my backtick key on my Mac, which is under the tilde key.

const cost = 0; const unitsPurchased = 100; let total = 'Total cost is $(cost * unitsPurchased).` console.log(total);

3 Answers

Jordan Hoover
.a{fill-rule:evenodd;}techdegree seal-36
Jordan Hoover
Python Web Development Techdegree Graduate 59,268 Points

The console will most definitely take the backtick, I'm using it on a mac right now. If you want your template literal to work though make sure you are wrapping it in {}. So:

let total = `Total cost is ${cost * unitsPurchased}.`

I'll give you a big programming hint: 99.99% of the time the problem is something that you did that you're not seeing, not the hardware or underlying software. Even if the error message makes it look like this is the case.

Not saying that to be demeaning, just something that it took me a bit to learn as well.

My backtick is working fine, thanks for letting me test it against your code. I think it is my console that is not working well. I had to open up two other windows to avoid a syntax error that said the cost identifier was already declared. I did clear() the console, but it didn't help.

Jordan Hoover
.a{fill-rule:evenodd;}techdegree seal-36
Jordan Hoover
Python Web Development Techdegree Graduate 59,268 Points

That's not an error, you can't redeclare a variable. Just reassign it. So total = 1 or whatever new value.

Think about it in terms of a script. You wouldn't do this in one script:

let total = 1;
let total = 2;

Instead you'd do this:

let total = 0;
//whoops I guess its 1 now
total = 1;

Clear() will just get rid of the visible code on the screen not clear the cache. If you want to do that, just refresh the webpage.

Again you should probably be thinking, "what am I doing wrong?" not "why must the Chrome console that is being used by thousands of developers daily and maintained by Google broken for me personally?"

Hi Jordan,

Thanks for going through that, and helping me to think about what is wrong. I'm not sure I understand everything you area saying, as total is equal to a formula, which changes with the variables inside, but I will think about it.