JavaScript JavaScript Basics Working With Numbers The Mad Libs Challenge Revisited

Christina Power
Christina Power
838 Points

My prompt isn't showing. Could someone review my code please.

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

Luc de Brouwer
Luc de Brouwer
Full Stack JavaScript Techdegree Student 17,552 Points

Hi Christina,

You're doing a great job on this one, however you're confusing a few important concepts. You're mixing up how string concatenation works and when an expression should be ended with an ';'.

My advice for properly formatting your question would be to use the markup style sheet that treehouse provides when you ask a question. three ` 's at the beginning will start a code block and add 3 ` 's at the end will create a block that will show your code in a readable format unlike how it is displayed in one single line if you don't format your code.

Like this:

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

Can you figure out what is going wrong now? If not, please send me a message

1 Answer

Hey i know this answer is really late but i figured why not. In your markup for the first prompt you have the string in quotes then an equal sign to questionsleft. Instead of an equal sign it should be a + sign.

so var adjective = prompt('Please type an adjective'= questionsleft); should be var adjective = prompt('Please type an adjective' + questionsleft);

So the prompt command is returning the string 'please type an adjective and the string used for the questionsleft variable. I hope I explained this correctly. Im still new to Javascript so I'm learning also. If anything is wrong here please feel free to correct me.