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

give me the answer of quiz

some Question i can not answer

scripts.js
var answer = ("");
var visitorName =prompt("What day is it");
documentwrite("answer=visitorName");
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

Matthew Long
Matthew Long
28,407 Points

You have a few syntax errors and you're not fully doing what the questions are asking either. They can be picky.

The challenge never asked you to store the prompt in a variable named visitorName. So delete all of that and move the prompt up to the answer variable on line one. Next, pay attention to the exact text that these challenges as you to use, you left off the question mark. Most of the time leaving something like this off will cause a challenge to fail. Also you forgot the . between document and write. Lastly, when using a variable in a case like this you do not use quotation marks. Using quotation marks makes it a string and not a variable.

var answer = prompt("What day is it?");
document.write(answer);

Hope this helps!

In the second part of the challenge wants you to use the prompt() function to store the input in the variable called answer, which you made in the first part of the challenge. As you have already declared the variable you don't need to use the var keyword and it will look like this (this challenge is picky and needs the ? in order for you to pass):

answer = prompt("What day is it?");

For the third part of the challenge it wants you to use the document.write function to display the answer. In the code you have entered you need to add a . between document and write. To output a variable using this method you do not need to use any speech marks and can just use the variable name. This line of code should look like this:

document.write(answer);

Overall the entire group of challenges at the end will look like this:

var answer = ("");
answer = prompt("What day is it?");
document.write(answer);