JavaScript JavaScript Basics Working With Numbers The Mad Libs Challenge Revisited

B G
B G
1,866 Points

Not counting down after the first prompt

It will not count down after the first prompt

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' + questonsLeft );
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);

Moderator edited: Markdown added so that code renders properly in the forums.

4 Answers

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there! You have two small typos which are causing syntax errors and causing your program to stop running.

In two separate cases you have misspelled the variable name questionsLeft.

// your code
var verb = prompt('Please type a verb' + questonsLeft );

//corrected code
var verb = prompt('Please type a verb' + questionsLeft );  // note the "i" in questionsLeft

And here is a capitalization error:

// your code
var noun = prompt('Please type a noun' + questionsleft);

// corrected code
var noun = prompt('Please type a noun' + questionsLeft);  // note the L  

Always check your console for errors if something strange is happening. It's the best starting point to figure out what's wrong. Hope this helps! :sparkles:

Jong Kim
Jong Kim
6,145 Points

https://w.trhou.se/s2ed4kqklj

Could you please check mine too???

I have also counting problem. Everything goes well except for not counting down.

B G
B G
1,866 Points

Thank you. I guess my eyes are getting tired.

Jong Kim, your prompts are referencing to 'questionsLeft' but your objects in line 6 and 11 prior to the prompts says 'questionLeft' >>> notice the typo.

Jong Kim
Jong Kim
6,145 Points

Thank you Marvin!

Jennifer Nordell
Jennifer Nordell
Treehouse Staff

Frank Formica I would love to help but first, this should probably be posted as a separate question. Secondly, the link you have provided is private to you. If anyone else tries to view it we get a 404 with a Bummer! message. However, if you click the camera looking icon on the upper right side of your workspace, this will create a "snapshot" of your workspace which you then can link. We can use that link to fork your workspace and have a look around.

Hope this helps! :sparkles: