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 trialP M
3,672 PointsCannot get the app.js to work
I am building the console application in the node.js course to print out the users--name, badge count and points. I have just started and cannot get the console to print out the parameters when I am calling the function. It will print the message just as is in the console.
function printMessage(username, badgeCount, points) { const message = '${username} has ${badgeCount} total badges and ${points} points in JavaScript '; console.log(message); }
printMessage("chalkers", 100, 6905);
5 Answers
David Smith
6,556 PointsI found this very frustrating and while the answer is here its not very clear so I thought I spell it out for people like me who were confused by what a back tick was. A back tick is a ( ` ) not a ( ' ). The key you're looking for is found above the tab key on an English (windows/3rd party keyboard) I can't confirm if this is true for Mac users or other European countries. However after a little deep dive I did some places saying that it is alt + 9 on a European keyboard can someone confirm?
function printMessage(username, badgeCount, points) {
const message = `${username} has ${badgeCount} total badges and ${points} points in JavaScript` ;
console.log(message);
}
printMessage("chalkers", 100, 6905);
Michael Van Patter
2,848 PointsThanks @David Smith. It would have been helpful for that to be specified in the video.
Jessica Graham
6,878 PointsFor anyone wondering where to find this on a British or US-English keyboard, refer to this thread.
P M
3,672 Pointsyes, I should have thought of that :) Thank you Ashish, it worked.
Also, I realized that I was using normal quote marks and not backticks. I added the backticks and it worked.
Brian Foley
8,440 PointsThis is what happened to me. Thank you. I put the backticks in there and it worked.
P M
3,672 PointsNope, it prints out the message as is. ${username} has ${badgeCount} total badges and ${points} points in JavaScript.
I am calling the function with the specified parameters but the message is not getting updated. :(
Ashish Mehra
3,407 Pointsfunction printMessage(username, badgeCount, points) {
const message = '${username} has ${badgeCount} total badges and ${points} points in JavaScript ';
console.log(username);
console.log(badgeCount);
console.log(points);
console.log(message);
}
printMessage("chalkers", 100, 6905);
May be template literal is not compatible with your browser so I will suggest you to try old concatenation part.
Anthony Domina
Courses Plus Student 19,571 PointsThe tips above worked for me when I added the backticks at the front and end of the message variable. Thanks for the assist!
mike lyell
3,213 PointsSo why are we using back ticks and brackets, I feel like that came from no where? Did I miss something
Tom Couillard
19,866 PointsHey Mike, these are template literals in the teachers notes they have linked to a video about template literals it is new in ES6. They are much easier because they eliminate the need for concatenation in most places.
Ashish Mehra
3,407 PointsAshish Mehra
3,407 Pointsis there is any error in console.