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

Uncaught ReferenceError questions is not defined

the console is telling me that there is a problem on line 2 that is not opening the prompt but i cannot find it.

  1. var question = 3;
  2. var questionsLeft = ' [' + questions + ' questions left]';
  3. var adjective = prompt('Please type an adjective' + questionsLeft);
  4. var verb = prompt('Please type a verb');
  5. var noun = prompt('Please type a noun' + questionsLeft);
  6. alert('All done. Ready for the message?');
  7. var sentence = "<h2>There once was a " + adjective;
  8. sentence += ' programmer who wanted to use JavaScript to ' + verb;
  9. sentence += ' the ' + noun + '.</h2>;
  10. document.write(sentence);

1 Answer

Spencer Snyder
Spencer Snyder
4,030 Points

in line 2 you reference questions, but you have only defined question... hence the reference error. Change line 1 to var questions = .... or change line 2 to var questionsLeft = ' [' + question + ' questions left]';