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

My code isn't working even as I follow the video

Hello :)

I can't seem to get past this...my code it write very similar to displayed in the video but that last part of my code seems to to cancel the prompt from working. I am sure this is basic but I just can't work it out... my code below :)

var adjective = prompt("Give me a adjective?");
var sentence = "<h2>Once there was a " + adjective;
var noun = prompt("Give me a noun?");
var verb = prompt("Give me a verb");
var sentence += " dog who liked use computers to " + verb;
var sentence += " the " + noun + ".</h2>";
document.write(sentence);

1 Answer

I worked it out.... I just needed to remove the var from the second 2 sentence syntax.

Correct code is...

var adjective = prompt("Give me a adjective?");
var sentence = "<h2>Once there was a " + adjective;
var noun = prompt("Give me a noun?");
var verb = prompt("Give me a verb");
sentence += " dog who liked use computers to " + verb;
sentence += " the " + noun + ".</h2>";
document.write(sentence);
Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Kiwi.

just to let you know, I have changed your comment into an answer so that you can mark it down as best answer and close the thread.

Good job!!

Vitto