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

JavaScript

JavaScript Basics challenge story.js

I successfully completed the story.js challenge, with one little issue: I can't figure out how to make 'spaces' between two different variables that are being added together.

So if I have, for example:

var message = 'A ' + noun1 + ' and a ' + adjective1 + noun1 + 'the rest of the string';

document.write(message);

How do I make the browser print a space between adjective1 and noun1?

Thanks!

3 Answers

Hi Megan,

Just add a string containing a space between them.

adjective1 + " " + noun1

You can Add the Space in single quotes.

Like this:

var message = 'A ' + noun1 + ' and a ' + adjective1 + ' ' + noun1 + 'the rest of the string';

Thank you both! Worked perfectly. . . . (-: