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 trialTushar Singh
Courses Plus Student 8,692 PointsWhy prompt is not working
var noun = prompt("Enter any noun"); var adjective = prompt("Enter any adjective"); var verb = prompt("Enter any verb"); var done = alert("Are you ready for a fucking nice story?"); var noAdjVerb = "<h2>Once there was an " + adjective + " " + noun + ", his favourite hobby was to " + verb ". </h2>" document.write(noAdjVerb);
2 Answers
Tobias Helmrich
31,603 PointsHey Tushar,
you only have one tiny mistake which is that you didn't concatenate the last String in your noAdjVerb
variable, so you have to add one additional "+" after you're concatenating the verb
variable and it should work.
Like so:
var noun = prompt("Enter any noun");
var adjective = prompt("Enter any adjective");
var verb = prompt("Enter any verb");
var done = alert("Are you ready for a fucking nice story?");
var noAdjVerb = "Once there was an " + adjective + " " + noun + ", his favourite hobby was to " + verb + ". "
document.write(noAdjVerb);
I hope that helps! :)
Tushar Singh
Courses Plus Student 8,692 Pointsooh man! I forgot that lol..Thanks. I have 1 more question though.
How do you post stuff as if you are just importing code from the workspace??
It says add ''' before and after the code. That's it?
Tobias Helmrich
31,603 PointsTo format the code properly you have to use markdown syntax. In the beginning you have to write three backticks (`), make sure they're backticks and not single quotes ('), then you can write the language you want your code to be formatted in (in this case you write javascript) immediately after the first three backticks. Then you can write your code beginning from the next line and when you're done you close the code block by writing three backticks again.
I hope that makes sense, in the beginning it can be a bit confusing but once you'll get the hang of it it's really easy! :)
Tushar Singh
Courses Plus Student 8,692 Pointsvar noun = prompt("Enter any noun");
var adjective = prompt("Enter any adjective");
var verb = prompt("Enter any verb");
var done = alert("Are you ready for a fucking nice story?");
var noAdjVerb = "Once there was an " + adjective + " " + noun + ", his favourite hobby was to " + verb + ". "
document.write(noAdjVerb);
Tobias Helmrich
31,603 PointsPerfect, you almost got it right! Just make sure to write the three backticks in the end in a new line.
Tushar Singh
Courses Plus Student 8,692 PointsThanks! got it ;)
Tushar Singh
Courses Plus Student 8,692 PointsTushar Singh
Courses Plus Student 8,692 Pointsvar noun = prompt("Enter any noun");
var adjective = prompt("Enter any adjective");
var verb = prompt("Enter any verb");
var done = alert("Are you ready for a fucking nice story?");
var noAdjVerb = "<h2>Once there was an " + adjective + " " + noun + ", his favourite hobby was to " + verb ". </h2>"
document.write(noAdjVerb);