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 trialRafael Cruz-Camacho
1,215 PointsHow 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?
let firstName= 'Carlos';
let lastName= 'Salgado';
let role = 'developer';
const msg = firstName + ' ' + lastName + ':' + role;
5 Answers
Shem Ogweno
15,393 PointsHi Rafael, Here is one way to solve it!
let firstName= 'Carlos';
let lastName= 'Salgado';
let role = 'developer';
const msg = firstName + ' ' + lastName + ':' + ' ' + role.toUpperCase();
Shem Ogweno
15,393 Pointsanother way is to use Template literals.
let firstName= 'Carlos';
let lastName= 'Salgado';
let role = 'developer';
const msg = "#{firstName lastName : role.toUpperCase()}";
James Summers
704 PointsIt works for me, I don't think you are doing anything wrong
James Summers
704 PointsI 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
1,215 PointsI appreciate your help. I can't believe that silly little space had me stumped, lol.
James Summers
704 PointsYou're welcome!