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 trialJames Voss
187 PointsI am confused on the answer to this question. Can anyone help me out?
let firstName = 'James';
let lastName = 'voss';
let role = 'developer';
const message =' firstName +' lastName + ': += role.'
2 Answers
Clinton Hays
Front End Web Development Techdegree Graduate 18,156 PointsHey James Voss!
Hope you got the information you needed. I just wanted to pop in and maybe give you some idea on why your answer didn't work originally.
When we assign strings to variables, all we need to do is call the variable to access the string later. Remember, variables are just containers for information. Let's look at your variables:
let firstName = 'James'; // we can now just call firstName and JS will know the content is 'James'
let lastName = 'voss'; // call lastName and JS will know the content is 'voss'
let role = 'developer'; // call role and JS will know the content is 'developer'
So when we build our msg
string all we need to do is call the variables and concat some spaces:
let msg = firstName + ' ' + lastName + ': ' + role // output = James voss: developer
I hope this helps. This is a really fundamental part of being a developer and it will only get easier the more you do it! Good luck and happy coding!
Salwa Elmohandes
Full Stack JavaScript Techdegree Graduate 20,240 Pointslet firstName='Carlos';
let lastName='Salgado';
let role = 'developer';
let msg= firstName + ' ' + lastName + ': ' + role.toUpperCase();
James Voss
187 PointsJames Voss
187 PointsThank you very much for the help! I am starting to get more and more comfortable learning this everyday!
Clinton Hays
Front End Web Development Techdegree Graduate 18,156 PointsClinton Hays
Front End Web Development Techdegree Graduate 18,156 PointsMy absolute pleasure! It really starts to snowball and soon you'll be doing things like they're second nature!