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 trialCarlos Jimenez
Courses Plus Student 4,242 PointsJavaScript 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 ;)
let firstName = 'Carlos';
let lastName = 'Jimenez';
let role = 'developer';
let msg = firstName + lastName: + role;
2 Answers
Bramyn Payne
19,589 PointsfirstName
, 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
Courses Plus Student 4,242 Pointslet 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.