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
mrx3
8,742 PointsI can't figure out how to add space to two strings I'm trying to concatenate.
I have a prompt box that has the user enter their first name and last name, and it's supposed return their name with a couple of messages.
For example, if you enter Matt Damon the program returns MattDamon. I would like the program to return Matt Damon. Any help would be appreciated.
Here's my codepen http://codepen.io/mike316/pen/ZbYYOz
2 Answers
Andrew Rodman
9,681 PointsYou could simply add + " " + in between firstname and lastname.
Ryan Holdeman
8,067 PointsEasy fix, all you have to do is concatenate a space in between your firstName and lastName variables.
var message ="Hello " + firstName + " " + lastName;
If you have any questions let me know.
Ryan
mrx3
8,742 PointsThank you Ryan for your help. I really appreciate it!!!!!
mrx3
8,742 Pointsmrx3
8,742 PointsThanks Andrew, I thought it was something like that, I'm new to JavaScript and really appreciate your help. Thank you again.