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 trialRyan Morrison
187 PointsBelow role, create a new variable named msg that combines the firstName, lastName and role variables to create a string
let firstName ="Ryan";
let lastName = "Morrison";
let role = 'developer';
let msg = +firstName''+lastName+': '+role;
1 Answer
Zimri Leijen
11,835 PointsClose, but there's a few small issues here.
The first plus is unnecessary, and will actually be interpreted as "parse as number" so the first string will become a type of number, and therefore will become NaN. The solution is to not have the first +.
FirstName is directly followed by quotemarks, there actually need to be a + in between there. Also it seems you may have forgotten about the space in between the quotemarks.
In it's simplest form you can simply do firstName + lastName + role
, of course, if you want spaces and other things you can do something like firstName + ' ' + lastName + ': ' + role
Brian Fitzgerald
2,691 PointsBrian Fitzgerald
2,691 PointsI follow you code exactly and get "Cannot read property '1' of null on every variation. This challenge has me baffled - have gone over he video's numerous times. Am I missing something here?
Zimri Leijen
11,835 PointsZimri Leijen
11,835 Pointscan not read property 1 of null? What?
What is your code that produces that error?
let msg = firstName + ' ' + lastName + ': ' + role;
or
let msg = `${firstName} ${lastName}: ${role}`;