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

Shadrach Thomas
PLUS
Shadrach Thomas
Courses Plus Student 8,915 Points

document.write()

do know how to solve this

scripts.js
var answer = prompt("What day is it?");
var document.write('smack');
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

Thomas Fildes
Thomas Fildes
22,687 Points

Hi Shadrach,

You will use document.write to write the answer variable with the following code:

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

document.write(answer);

Hope this helps! Happy Coding!!!

Shadrach Thomas
Shadrach Thomas
Courses Plus Student 8,915 Points

please how can i just skip to the real deal i think the way the trial is treating me is not fair i do get somethings right but end up failing it not cool, i really want to learn how to code so good

Thomas Fildes
Thomas Fildes
22,687 Points

It is perfectly natural to be hit with a loss of confidence when struggling with challenges. This is called Imposter Syndrome. You can overcome it by not worrying that you fail challenges and that mistakes make us successful in coding.

Keep at it and you will learn from these mistakes to be great at writing code. Every developer makes mistakes!

Pace yourself through the track/course gradually and you will pick it up :)

Hi Shadrach

You have to use the method document.write(), it's not a variable, so take the "var" before document.write(). Then you need to call the variable answer:

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