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

I'm at the Challenge Task 1 of 3 in the JavaScript lesson: app.js "Assign your first and last name blah blah. HELP!!!

It's not actually clear on what is needed to be done. Am I to have a question in prompt? Am I to capture info, combine strings... What? In the videos prior to this doesn't explain in details what this is about...

let firstName can be const firstName let lastName can be const lastName I can have it prompt to console.log or alert

let role (not sure what this is) but I can string firstName + lastName

Now I can't get past this area

app.js
let firstName (Guil);
let lastName (Something);
let role = 'developer';

1 Answer

Hi Gypsy!

This passes the first challenge:

let firstName = 'Gypsy' ;
let lastName = 'Miles';
let role = 'developer';

This passes the second challenge:

let firstName = 'Gypsy' ;
let lastName = 'Miles';
let role = 'developer';

let msg = firstName + " " + lastName + ": " + role;

This passes the third challenge:

let firstName = 'Gypsy' ;
let lastName = 'Miles';
let role = 'developer';

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

This would also work for the last line (using template literals):

let msg = `${firstName} ${lastName}: ${role.toUpperCase()}`;

(Using ES6 syntax)

(Also please notice the backticks used in the last line of code)

More info:

https://masteringjs.io/tutorials/fundamentals/string-concat

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

https://css-tricks.com/template-literals/

I hope that helps.

Stay safe and happy coding!