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 Node.js Basics 2017 Building a Command Line Application Making a GET Request with https

P M
P M
3,672 Points

Cannot 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);

function printMessage(username, badgeCount, points) { 
const message = '${username} has ${badgeCount} total badges and ${points} points in JavaScript '; console.log(message);
 }

printMessage("chalkers", 100, 6905);

is there is any error in console.

5 Answers

I 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
Michael Van Patter
2,848 Points

Thanks @David Smith. It would have been helpful for that to be specified in the video.

Jessica Graham
Jessica Graham
6,878 Points

For anyone wondering where to find this on a British or US-English keyboard, refer to this thread.

P M
P M
3,672 Points

yes, 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
Brian Foley
8,440 Points

This is what happened to me. Thank you. I put the backticks in there and it worked.

P M
P M
3,672 Points

Nope, 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. :(

function 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
PLUS
Anthony Domina
Courses Plus Student 19,571 Points

The tips above worked for me when I added the backticks at the front and end of the message variable. Thanks for the assist!

So why are we using back ticks and brackets, I feel like that came from no where? Did I miss something

Hey 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.