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.

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables The Variable Challenge Solution

Bryan Becker
Bryan Becker
8,849 Points

Why doesn't my code work for this challenge?

Wondering what's wrong with this code and why it wont work for the challenge?

"<h2>There once was a [adjective] programmer who wanted to use JavaScript to [verb] the [noun].</h2>"

var adjective = prompt('Please give me an adjective'); var verb = prompt("Please give me a verb"); var noun = prompt("Please give me a noun"); alert("All done. Ready for the message?"); var sentence = "<h2>There once was a" + adjective + "programmer who wanted to use JavaScript to " + verb + "the " + noun."</h2>";

document.write(sentence);

1 Answer

Aaron Kaye
Aaron Kaye
10,936 Points

Your final sentence is a bit off. This is how it should be:

var sentence = "There once was a" + adjective + "programmer who wanted to use JavaScript to " + verb + "the " + noun+".";

The change is the after the noun I concatenated the period as another string.

Bryan Becker
Bryan Becker
8,849 Points

Thank you! That seemed to take care of the problem.