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

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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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!

https://teamtreehouse.com/workspaces/39014582#

mine is not counting down either

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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: