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

Shima Bahre Abdalla
Shima Bahre Abdalla
1,729 Points

Hi, this question is really challenging me can I get help?

app.js
let firstName = "shima";
let lastName = "abdalla";
let role = 'developer';

let msg = firstName + ' ' + lastName +':' + role + '.';
let msg = role.toUpperCase();

1 Answer

Bella Bradbury
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Front End Web Development Techdegree Graduate 32,790 Points

Hello Shima!

There's just a few things that need to be changed to get you passing this challenge. The first thing we can do is delete the bottom line of code and put the .toUpperClass() method into our top msg variable. A few key things to point out:

  • The message variable is already defined with let msg so if we wanted to change it in the future all we'd have to do is write the variable name msg. You can't define (aka use let, const, or var) two variables with the same name!
  • This code is synchronous which means that it's going to execute one line of code and then continue on to the next. Even if we were to delete the let out of the second message line it still wouldn't work. You'd be telling the code to forget the previous message and instead make the message just the role in upper case.

After deleting the bottom line and adding the method to the msg variable our code should now look like this:

let firstName = "shima";
let lastName = "abdalla";
let role = 'developer';

let msg = firstName + ' ' + lastName +':' + role.toUpperCase() + '.';

From here we just have to change how we're concatenating the variables. Let's see how our current message compares to the desired one in the challenge:

// current message
shima abdalla:DEVELOPER.  

// desired message
shima abdalla: DEVELOPER

By writing out what we've written and comparing it, we can see that we need to put a space after the colon and delete the period at the end of the message. Once we do that we have our final code:

...

let msg = firstName + ' ' + lastName +': ' + role.toUpperCase();

Hope this helps!

Shima Bahre Abdalla
Shima Bahre Abdalla
1,729 Points

Thank you dear. But, it does not work.

Bella Bradbury
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Bradbury
Front End Web Development Techdegree Graduate 32,790 Points

If I replace the existing code in the challenges by copy and pasting your three variables (represented with the ... in my answer above) and then copy and paste the final msg variable at the end of my answer I'm able to pass the challenge.

let firstName = "shima";
let lastName = "abdalla";
let role = 'developer';

let msg = firstName + ' ' + lastName +': ' + role.toUpperCase();

I just passed the complete challenge multiple times with this code, you can literally copy and paste the above code and it should get you past all three steps. If you're copying the above code and it's not working please comment with the complete code you're submitting and then let me know what the error message reads!