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

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
704 Points

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

James Summers
James Summers
704 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.