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 trialMark Trevathan
10,652 PointsTemplate Literal formatting issue
In the video, her solution is to correct the quotations in:
console.log("Treehouse has ${i} JavaScript courses, and ${teachers.length} Javascript teachers");
However, this still would not work for me until I changed it to:
console.log("Treehouse has " + i + " JavaScript courses, and " + teachers.length + " Javascript teachers");
Any ideas?
Edit: I see this didn't post to the video in question. It is this video: https://teamtreehouse.com/library/practice-let-and-const-in-javascript/the-solution#questions
If link is broken, it is a solution video for practicing let and const variables in JavaScript.
1 Answer
Travis Alstrand
Treehouse Project ReviewerHey there Mark Trevathan ! 👋
The use of ${}
is how we can plug variables into strings as template literals. To do it this way, we need to wrap the string in backticks (on the same key as the Tilde ~
on most keyboard layouts) instead of quotation marks. It's still a valid and convenient approach 👍
Mark Trevathan
10,652 PointsMark Trevathan
10,652 PointsInteresting! Thank you very much for your response!
By the way, I just went back and watched the video again and I was completely mistaken about the quotes. Not sure where I pulled that from!
Travis Alstrand
Treehouse Project ReviewerTravis Alstrand
Treehouse Project ReviewerIt happens! It's a very easy thing to miss!
And you're very welcome 👍