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

Sebastian Angelo-Perez
Sebastian Angelo-Perez
1,835 Points

My Storymaker is done. is it a better/shorter way to do it?

var noun = prompt("say a noun"); var verb = "Say a verb"; var verb = prompt("You said " + noun + ", good! Now, " + verb); var adjective = "say an adjective"; var adjective = prompt("You said " + verb + ", your answer is correct! Now, " + adjective); alert("Great! You're finished");

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

You could eliminate the first declarations for your 'verb' and 'adjective' variables, as they are not needed. What you have stored in the variable can just be put into the concatenation, and therefore makes it less 2 lines. :)

var noun = prompt("Say a noun.");
var verb = prompt("You said " + noun + ". Now say a verb");
var adjective = prompt("You said " + verb + ". Now say a adjective");
alert("Great! You're finished. You're story says '" + noun + " " + verb + " " + adjective + ".'");