Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Node.js Basics 2017 Handling Errors in Node Handling Status Code Errors

Kenneth Kim
Kenneth Kim
3,795 Points

Hi can anyone help me with this syntax

const errorMessage = `There was an error getting the profile of ${username} (${response.statusCode})

I understand ${username} but the next one is confusing to me. Why does it have parenthesis around the variable ${response.statusCode} ?

1 Answer

Bruno Navarrete
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bruno Navarrete
Full Stack JavaScript Techdegree Graduate 22,233 Points

It's just to make it readable, you could enclose the ${response.statusCode} in whatever you wanted inside your template string.

const errorMessage = `There was an error getting the profile of ${username} (${response.statusCode})`;
// will return something like "There was an error getting the profile of Clark Kent (400)";

const errorMessage = `There was an error getting the profile of ${username} --- ${response.statusCode} --- `;
// will return something like "There was an error getting the profile of Clark Kent --- 400 ---";