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 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,948 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.