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 (Retired) Storing and Tracking Information with Variables The Variable Challenge Solution

Spaces

Please let me know what you guys think and also how the flow is ..

I need some thought on how I can get better and how I can properly add spaces in between the the sentence.

//prompt comands//

var name = prompt("Tell me your name"); var adjective = prompt("Give me an adjective"); var noun = prompt("Give me a noun"); var verb = prompt("Give me a verb"); alert("We are all set. Ready for the story");

//Story//

var storyMaker = "Once upon a time we had the hero of the story named " + name + "The hero of the story really likes to " + verb; storyMaker += "The hero rushed too see the" + noun + "because of the" + adjective;

document.write(storyMaker);

1 Answer

Steven Parker
Steven Parker
229,786 Points

You just need to include the spaces in the literal strings. You may also want to throw in some punctuation and line breaks:

var storyMaker = "Once upon a time we had the hero of the story named " + name + ".<br>";
storyMaker += "The hero of the story really likes to " + verb + ".<br>";
storyMaker += "The hero rushed too see the " + noun + " because of the " + adjective + ".<br>";

Oh wow so you can add the <br> just as HTML. Cool.

Other than that do you think the code looks organized and clean?

Steven Parker
Steven Parker
229,786 Points

It's hard to tell with it unformatted. When posting code, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

But this program is perhaps a bit too small to serve as a good example of organization.