JavaScript JavaScript Basics Working With Numbers The Mad Libs Challenge Revisited

what am i missing?

what is my code missing?

```var questions = 3; var questionsLeft = '[' + questions + ' questions left']'; var adjective = prompt('Please type an adjective' + questionsLeft);

questions -= 1; var questionsLeft = '[' + questions + ' questions left']'; var verb = prompt('Please type a verb' + questionsLeft);

questions -= 1; var questionsLeft = '[' + questions + ' questions left']'; var noun = prompt('Please type a noun' + quetionsLeft); 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);```

Cooper Runstein
Cooper Runstein
11,791 Points

I see you intended to format your response as code, next time make sure to add a new line after the "```".

var questions = 3; 
var questionsLeft = '[' + questions + ' questions left']'; 
var adjective = prompt('Please type an adjective' + questionsLeft);

questions -= 1; 
var questionsLeft = '[' + questions + ' questions left']'; 
var verb = prompt('Please type a verb' + questionsLeft);

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

Cooper Runstein
Cooper Runstein
11,791 Points

You keep redeclaring questionsLeft which is making you code fail, you're also incorrectly ending your strings when you do so:

var questionsLeft = '[' + questions + ' questions left']'; //5 quotes, you should have an even number.

You have several issues. I won't tell you exactly what they are but I will tell you where they are.

  1. 'var questionsLeft': look at "questions left']';" and fix something there.
  2. You have typo in "var noun".
  3. In "var sentence" you're calling the prompt variables incorrectly. You only need to call the variable name. Don't forget to add the '+' before and after the variables to concat.
var questions = 3;
var questionsLeft = '[' + questions + ' questions left]';

var adjective = prompt('Please type an adjective' + questionsLeft);
questions -= 1;
var questionsLeft = '[' + questions + ' questions left]';

var verb = prompt('Please type a verb' + questionsLeft);
questions -= 1;
var 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 + ' programmer who wanted to use JavaScript to ' + verb + ' the ' + noun + '.</h2>';

document.write(sentence);