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 trialTroy Anderson
647 PointsUse the document.write() method to write the variable answer to the page.
I get the Bummer error message that reads it look like you put the doucment.write method in the wrong place
var answer
user = prompt("What day is it?")
answer = prompt("What day is it?")
document.write(answer)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="scripts.js"></script>
</body>
</html>
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! You're doing fine, but for some reason you have an extra line of code that was never asked for by the challenge. You may safely delete:
user = prompt("What day is it?")
Also, your code contains no semicolons at the end of the statements. While this does not affect this challenge in any way, it could potentially affect other challenges. JavaScript has automatic semi-colon insertion, but sometimes, Javascript gets it wrong and the results can vary wildly from what you were expecting. I'd suggest getting used to adding a semicolon after every statement.
Hope this helps!
Troy Anderson
647 Pointspart of the challenge test ask you to assign a user prompt that ask "What day is it ?" and it's the only way it passes the second statement also the document.write() method fails with the Bummer error message that reads it looks like you placed the document.write in the wrong place. I will try your suggestions with semi-colons, thanks for your reply Jennifer
Jennifer Nordell
Treehouse TeacherJust to clarify, here are the instructions for Step 2:
Use the prompt() method to ask the user "What day is it?" and store the result in the answer variable.
It says to store the result in the answer
variable. Which you did in the third line so it passed, but the first line and the third line were all you needed to pass step 2. You included the extra line which does an additional prompt for the day and assigns it to a variable named user
which was never asked for.