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

can anyone help me with this task. thx

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

why do you have the name there twice?

name isn't even a variable

4 Answers

Steven Parker
Steven Parker
231,275 Points

It looks like you have a few issues:

  • nothing called "name" has been defined
  • there should not be an empty space at the beginning or end of your firstName or lastName string value
  • make sure you're adding one space (" ") between firstName and lastName
  • make sure you're concatenating ": " to lastName and role
let firstName = 'Carlos';
let lastName = 'Salgado';
let role = 'developer';
const msg = firstName + " " + lastName + ": " + role;

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

what am i doing wrong ?

Steven Parker
Steven Parker
231,275 Points

Compare the last line to the example in my answer.

Done! It's showing sthis msg: Cannot read property '1' of null

Steven Parker
Steven Parker
231,275 Points

The example in my answer passes task 2. You must still have something different.

let firstName = 'Carlos'; let lastName = 'Salgado'; let role = 'developer'; const msg = firstName + "Carlos " + lastName "Salgado: " + role;

Steven Parker
Steven Parker
231,275 Points

Your code is still different, comparing to the example code in my answer should make the problem clear.

let firstName = 'Carlos'; let lastName = 'Salgado'; let role = 'developer'; const msg = firstName + "Carlos" + lastName + "Salgado: " + role;

Make sure you're adding one space (' ') between firstName and lastName.

am i missing the space ? "Carlos " like tihis ?

OK! thx vreu much!