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 trialJames Barshaw
9,284 Pointslearning more about strings and numbers
I followed the teaching and something is wrong with my code and I don't understand enough to fix it 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'); 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);
1 Answer
philippulbrich
11,975 PointsHi James, if you want to use smth like questionsleft you can use loops. So it will count after every questions. Otherwise your code is correct but you have to write += instead of + = .
Best regards - Phil
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');
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);