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

i am back with basic JavaScript question

here it is.

scripts.js
var answer = prompt("What day is it?");
document.write"(Monday"); 
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>
Joseph Zimmerman
Joseph Zimmerman
6,402 Points

What's happening is your prompting the user and the storing it in the variable answer. You then write the prompted variable to the page. Also, you need to move your quote on the variable inside the parenthesis.

change the last line to: document.write("answer");

8 Answers

Joseph Zimmerman
Joseph Zimmerman
6,402 Points

are you trying to alert the answer from the prompt?

alert(answer);

thanks! i see that

it says the first code doesn't work now. why?

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script src="javascript.js"></script> <script> alert("Warning!"); </script>

</body> </html>

Joseph Zimmerman
Joseph Zimmerman
6,402 Points

That's where you lose me that challenge does not require an alert.

<script src="javascript.js"></script> <script> alert("Warning!"); </script> where is the problem that makes the first code stop working?

i know, it is so simple, isn't it? but it is not going through for some reason.

Joseph Zimmerman
Joseph Zimmerman
6,402 Points

Please provide complete code examples. Your code above does not have an alert.

Todd, I am going trough beginning lessons in JavaScript and the problem tells you specifically to use document.write().

Todd MacIntyre
Todd MacIntyre
12,248 Points

Paste the challenge instructions and the code you are trying to use here please so I can take a look.

Got it! Thanks guys!