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) Working With Numbers The Mad Libs Challenge Revisited

Angela Poldervaart
Angela Poldervaart
3,192 Points

Code doesn't work

Hi there, I'm really confused about something. I typed the code exactly as he did in the video, but when I preview it nothing happens. Well, the prompt code is working but it isn't saying how many questions are left or no story showing up after I typed an adjective, noun and verb and an alert won't show up either. I just don't get it because the code is exactly the same as in the video. Is this a bug?

4 Answers

Angela Poldervaart
Angela Poldervaart
3,192 Points

This is weird. It seems like the problem solved itself. I changed nothing in my code and everything is suddenly working now. Anyway, thank you guys! :)

anil rahman
anil rahman
7,786 Points

Link your workspace or if it's small amount of code just copy and paste it here.

No it not a bug its working for me...Here is my code....

var question = 3; var questionLeft = "[" + question + " question left]"; var adjective = prompt('Please type an adjective'+ questionLeft);

question -= 1; questionLeft = "[" + question + " question left]"; var verb = prompt('Please type a verb'+ questionLeft);

question -= 1; questionLeft = "[" + question + " question left]"; var noun = prompt('Please type a noun' + questionLeft);

alert('All done. Ready for the message?');

var sentence = "<h2>There once was a " + adjective; sentence += ' programmer who wanted to use JavaScript to ' + verb; sentence += ' the ' + noun + '.</h2>'; document.write(sentence);

Tristan Lawrence
Tristan Lawrence
3,582 Points

You can try using CTRL+Shift+J and view the error on the console. I think it may be in areas of slow internet connection but what I think has happened is that it may not have successfully saved all your code. Viewing in the console.log area you might be able to see which line it has failed. In my instance it failed at line4 and said that I didn't define questionsLeft when in fact I did. Hope this helps.