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) Storing and Tracking Information with Variables Capturing Visitor Input and Writing It to the Page

Use 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

scripts.js
var answer
user = prompt("What day is it?")
answer = prompt("What day is it?") 
document.write(answer)
index.html
<!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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi 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! :sparkles:

part 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
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Just 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. :smiley: