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

Rafael Cruz-Camacho
Rafael Cruz-Camacho
1,215 Points

How do I Add : to a string

Hi, I am stuck trying to complete challenge 2 of 3 on combing strings. What am I doing wrong?

app.js
let firstName= 'Carlos';
let lastName= 'Salgado';
let role = 'developer';
const msg = firstName + ' ' + lastName + ':' +  role;

5 Answers

Hi Rafael, Here is one way to solve it!

let firstName= 'Carlos';
let lastName= 'Salgado';
let role = 'developer';
const msg = firstName + ' ' + lastName + ':' + ' ' + role.toUpperCase();

another way is to use Template literals.

let firstName= 'Carlos';
let lastName= 'Salgado';
let role = 'developer';
const msg = "#{firstName lastName : role.toUpperCase()}";
James Summers
James Summers
691 Points

It works for me, I don't think you are doing anything wrong

James Summers
James Summers
691 Points

I just figured it out! I think you forgot a space between : and developer. This is what it should look like: const msg = firstName + ' ' + lastName + ':' + ' ' + role;

Rafael Cruz-Camacho
Rafael Cruz-Camacho
1,215 Points

I appreciate your help. I can't believe that silly little space had me stumped, lol.