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.

Tobi Ogunnaike
2,242 PointsCan anyone suggest a more elegant way of adding the periods to my code? Thanks
Here's my code
var statement1 = "What a coincidence, I can't believe your name is " + prompt("Hey, what is your name?" );
var statement2 = " I recently visited " +prompt("Where were you born?" );
var statement3 = " Let's go to " +prompt("What's your ultimate holiday destination?")+ " together";
document.write (statement1 + ".");
document.write (statement2 + ".");
document.write (statement3 + ".");
There should be a way to fit the periods into the first 3 lines of code but I can't figure out how. Thanks!
3 Answers

Rebecca Bompiani
16,945 PointsHi Tobi-
I think you could concatenate them the same way you started:
var statement1 = "What a coincidence, I can't believe your name is " + prompt("Hey, what is your name?" )+".";
Chris Grazioli
31,225 PointsYou could just make one long formatted string that contains your whole var story;
- like the "children's mad lib" they referred to in the video. The "mad lib" would contain blank spaces or your variables, response1, response2, etc.
Put this long formatted string after all the prompts and display it to the page with the document.write(story);

Tobi Ogunnaike
2,242 PointsThanks Rebecca!
Tried that before but it didn't work. Must've been a syntax issue