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 trialJustin Klebieko
283 PointsI can't figure out what's wrong with my code.
The prompts are working but after I've entered the adjective, verb and noun the story doesn't post to the screen.
"<h2>There once was a [adjective] programmer who wanted to use JavaScript to [verb] the [noun].</h2>"
var adjective = prompt("Please type an adjective"); var sentence = "<h2>There once was a " + adjective; var verb = prompt("Please type verb"); var noun = prompt("Please type noun"); alert("All done. Ready for the message?"); sentence += " programmer who wanted to use JavaScript to " + verb; sentence += " the " + noun + ".</h2>"; document.write(sentence);
7 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsit worked for me. i put your code verbatim in script tags and it worked fine.
Matthew Beiswenger
6,814 PointsI tried your code and it worked for me as well. Maybe try closing the browser and clicking preview again.
Justin Klebieko
283 PointsThanks for the help. I thought I was going crazy. What are some good JavaScript IDEs y'all recommend and why do you think it's not working on my computer? I'm doing the programmer from a Microsoft Surface Pro 3 with Windows 10 as my OS and Chrome as my browser.
Justin Klebieko
283 Points" i put your code verbatim in script tags and it worked fine." What does that mean James South?
Marius Totea
2,239 PointsVerbatim means putting your code into his workspace word by word. Have you checked if you delcared your javascript file into your html file? And it worked for me as well.
Matthew Beiswenger
6,814 PointsThe prompts wouldn't be working if the JavaScript file wasn't correctly linked.
Justin Klebieko
283 PointsI'm just starting out so bear with me. How would I link it to the HTML file? Thanks for the help. I appreciate it. I really want to get good at this.
Justin Klebieko
283 PointsHere's my new code for the next assignment. The same thing is happening. It just asks me to enter a verb, noun and adjective then doesn't post it to the screen nothing else happens. Could it be a virus? Do I need to download something? ugh
var questions = 3; var questionsLeft = ' [' + questions + ' questions left]'; var adjective = prompt('Please type an adjective'); 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'); 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);