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 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,246 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 ---";