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

Carlos Jimenez
PLUS
Carlos Jimenez
Courses Plus Student 4,242 Points

JavaScript challenge question

let msg = firstName + lastName: + role; I keep getting "Cannot read property '1' null, and "Make sure you have spaces" between firstName, and lastName." I have tried every combination I can think of and have taken photos of all them. Help!!! plz ;)

app.js
let firstName = 'Carlos';
let lastName = 'Jimenez';
let role = 'developer';

let msg = firstName +  lastName: +  role;

2 Answers

firstName, lastName, and role are all strings, so you need to concatenate them with additional strings of colons and spaces to get the correct formatting.

For example:

let greeting = "Hello";
let name = "John";
let message = greeting + ", " name;

Hope this helps

Carlos Jimenez
PLUS
Carlos Jimenez
Courses Plus Student 4,242 Points

let msg = firstName + ' ' +lastName +' : ' +' ' + role; This was final correct answer to the challenge question. I have intentionally added spacing to view more comfortably here. The string concatenation must be used with + and spacing between objects to be right thanks for the insight.