Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Kanav Anand2,368 Points
How do I get spacing between two concatenated declared variables like firstName+lastName?
var firstName=prompt("please Enter First Name); var lastName= prompt("please Enter Last Name); document.write(firstName+lastName);
The result will be no spacing between the two. how do I get the space.
Jennifer NordellTreehouse Teacher
Hi there, Kanav Anand! You have a couple of options here. There's nothing particularly special about a space really. It's a character just like any other but we call it a white space because it has no visual representation. Or rather, the visual representation is a null space.
So you could do this:
console.log(firstName + " " + lastName);
Because these are separated with a space inside the backticks, the space will also be present in the log statement. If you have about 9 minutes, I highly suggest you take a look at this workshop.
Hope this helps!