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

Stuck on Challenge Task 3 of 3 use the document.write()

stuck on the task...i have re watched the videos what am i missing?

scripts.js
var answer=prompt("What day is it?");
prompt("What day is it?")
var answer=prompt("What day is it?) document.write =("Sunday");
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>
Richard Scott
Richard Scott
25,647 Points

Hi Robert

As you've declared the answer variable to "What day is it?" as a prompt response, whatever is entered will be assigned to that variable. so you don't need the second line of your code. the third line just needs the answer variable to be written to the document i.e all you need is

document.write(answer)

hope this makes sense! let us know if you're still stuck :)

2 Answers

document.write=Sunday;

// answer variable stores what you enter into the prompt
var answer = prompt("What day is it?");
// use document.write to write the answer on the screen
document.write(answer);