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

Joe Williams
Joe Williams
4,014 Points

How do I make a space appear in this alert in JavaScript?

Per the video, I am trying to make a fill-in-the-blank game using prompt.

However, when I use this code:

var adjective = prompt("Name an adjective"); 
var verb = prompt("Name a verb"); 
var noun = prompt("Name a noun"); 

alert("Perfect! I've got " + adjective + verb + noun + " stored into my memory."); 

The result is: "Perfect! I've got brownrunningfox stored into my memory!" (for example)

How do I put space in between those words?

1 Answer

Stefan Osorio
Stefan Osorio
16,419 Points

Exactly the same way you made all the other text appear: Concatenation!

-> "Perfect! I've got " + adjective + " " + verb + " " + noun + " stored into my memory."