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

Prompts not working and no story appears

Not sure what is going on here. Here is my code. Let me know what I am doing wrong.

var animal = prompt("Name an animal");

var part = prompt("Enter a part for your animal");

var animal_color = prompt("What color is your animal do?");

var action = prompt("What does your animal do?");

alert("Thanks. Your story will appear shortly");

document.write( "There once was a little "+ animal ", whose " part " was " + animal_color + ". "

"One day the little " + animal_color + animal " decided to " + action + ". "

"Thus, the little " + animal_color + animal + " became a great " + action + "or." );

1 Answer

You forgot some '+' to concat the strings/variables.

document.write( "There once was a little "+ animal + ", whose " + part + " was " + animal_color + ". " +
"One day the little " + animal_color + " " + animal + " decided to " + action + ". " +
"Thus, the little " + animal_color + " " + animal + " became a great " + action + "or." );