JavaScript JavaScript Basics Working With Numbers The Mad Libs Challenge Revisited

ae33
PRO
ae33
Pro Student 1,671 Points

Question counter stays the same. What am I doing wrong?

var questions = 3;
var questionsLeft = ' [' + questions + ' questions left]';

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

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 51,992 Points

After you decrement questions you update questions when I think you meant to update questionsLeft. Example:

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

should be:

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

Otherwise you are prompting the initial value of questionsLeft.

Victor Warner
Victor Warner
1,764 Points

same problem thank you for the help