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

Nicole Aiken
Nicole Aiken
631 Points

My prompt isn't showing up. Does anyone know what I'm doing wrong?

Hi. I'm unable to get the prompt to show up. Below is my code. Any help would be greatly appreciated. Thanks!

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

3 Answers

When you assigned the verb variable you accidentally put a space in question left as if it was a string

var verb = prompt('Please type a verb' + questions left )

it should be

var verb = prompt('Please type a verb' + questionsLeft )
Nicole Aiken
Nicole Aiken
631 Points

Ahhhh now I see! Thank you so much, Juan! Fixed it and it ran! Yay!

Thank you so much, Steven! Now I see that that's what you meant about the issue with my "questions left."

So thankful to you both for all of your help! Have a wonderful day :)

Steven Parker
Steven Parker
231,275 Points

It's hard to see unformatted, but one issue that stands out is where it says "questions left" (with a space and lower case "l") instead of "questionsLeft".

To make code easier to read, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

Nicole Aiken
Nicole Aiken
631 Points

Thanks so much for responding, Steven! I really appreciate the advice. Here's the code using the Markdown Cheatsheet instructions. As for "questions left" my understanding from the video was that it was different from questionsLeft, as it was just text. That way it would read, for example: "2 questions left." Does it appear that way to you now that I've formatted it? Are you able to see anything else that may be causing the prompt not to run? Thanks!

var questions = 3;
var questionsLeft = ' [' + questions + ' questions left]';
var adjective = prompt('Please type an adjective' + questionsLeft);
questions -= 1;
questionsLeft = ' [' + questions + ' questions left]';
var verb = prompt('Please type a verb' + questions left );
questions -= 1;
questionsLeft = ' [' + questions + ' questions left]';
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);
Steven Parker
Steven Parker
231,275 Points

As you saw, the separate words are OK in a string but not in the code.

You can mark the question solved by choosing a "best answer".
Happy coding!