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 JavaScript Basics Working with Strings Combine and Manipulate Strings

Works on Chrome console but not here?

Is there something wrong here? I tried this in Chrome dev tools and got the desired result, but not here.

app.js
let firstName = 'Kim';
let lastName = 'DiPasqua';
let role = 'developer';
let msg = `${firstName} ${lastName}: ${role}`;
let roleUpper = role.toUpperCase();
let msg = `${firstName} ${lastName}: ${roleUpper}`;

2 Answers

Hey Kimberly DiPasqua,

You have declared msg variable twice. let variable can be updated but cannot be re-declared.

There are two ways you can pass this challenge by using string concatenation or template literals. I will present you with both:

String Concatenation

let firstName = 'Kim';
let lastName = 'DiPasqua';
let role = 'developer';
let roleUpper = role.toUpperCase();

let msg = firstName + ' ' + lastName + ': ' + roleUpper;

Template literals

let firstName = 'Kim';
let lastName = 'DiPasqua';
let role = 'developer';
let roleUpper = role.toUpperCase();

let msg = `${firstName} ${lastName}: ${roleUpper}`;

To learn more about let variables, check out this website: https://www.w3schools.com/js/js_let.asp

Hope this helps!

Ohhhhhh d’oh! That makes a lot of sense now. Thank you very much! 🙂

Martin Sole
Martin Sole
82,199 Points

Hi

I think what the challenge is asking for is that toUpperCase is used on the role variable within the msg template literal.