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

Prompts are not executing, please help me review my code

Good day all,

My prompts are currently not executing and I was wondering what I can change to make the code work. Thanks in advance! I will post my code down below.

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

You can surround your code by triple backticks to make it more readable

var questions = 3;
var questionsLeft = ' [' + questions + ' questions left]';
var adjective = prompt('Please type an adjective' = questionsLeft); // seems you wrote an `=` here instead of a `+`
questions -= 1; 
questionsLeft = ' [' + questions + ' questions left]';
var verb = prompt('Please type a verb'); // not breaking but you forgot to include questionsLeft here
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);

alternatively, you can share snapshot of your workspace.

1 Answer

The = on line 3 is likely the problem.

prompt('Please type an adjective' = questionsLeft)

Thanks for your answer and the help Zimri!