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

Brandon lile
Brandon lile
1,271 Points

What did i do wrong?

can someone please check my code? I've followed along and did it step by step but i know i must be missing something. It won't bring up any prompts at all.

var questions = 3; var questionsLeft = ' [' + questions + ' questionsLeft]'; var adjective = prompt('Please type an adjective' + questionsLeft); questions -= 1; questionsLeft = ' [' = questions + ' questionsleft]'; var verb = prompt('Please type a verb' + questionsLeft ); questions -= 1; questionsLeft = ' [' + questions + ' questionsleft]'; var noun = prompt('Please type a noun' + questionsLeft); 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);

2 Answers

You've just made a small typo where your updating the question total for the adjective.

questions -= 1; questionsLeft = ' [' = questions + ' questionsleft]';

replace your equals with a plus

questions -= 1; questionsLeft = ' [' + questions + ' questionsleft]';

Run the code and it'll work a treat. Hope that helps. Thanks.

blake guyan
blake guyan
8,297 Points

try to reduce the code down and eliminate factors.. so remove all the code using comments

//this is what a comment looks like (just in case)

and uncomment it one action at a time. start with just that first prompt and run the program and see if it will work then, then uncomment your -= line and so on and so forth. its a good way to troubleshoot your code.