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) Introducing JavaScript Your First JavaScript Program

Tanner Bindrup
Tanner Bindrup
12,245 Points

it says i didn't call for document.write, I typed it in so im not sure how to place it?

document.write?

index.html
alert("hello from Treehouse");
document.write("</h1>Welcome to Javascript.</h1>");
alert("thanks for visiting.";
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>

<body>
</body>

<script>
// Hello, welcome to my site.

</script>

</html>

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Tanner,

Your code is a little off, and you went beyond what the challenge asked you to do. The 2 alerts you have and the added h1 tags will cause you to not pass, and the code should be inside the script tags.

Restart the challenge (refresh the page) so the original code is put back.

After the closing body tag, add the following code, as the challenge just wants you to use the document.write() method.

<script>
// Write your code here.
document.write("Welcome to my site")          //This is the only line you need to put in
</script>

</html>

Hope that helps. Keep Coding! :)

Abe Layee
Abe Layee
8,378 Points

Hi, you want to write your code in the script tag. The document.write() function outputs text on the screen. You want something like this

<script>
// Write your code here.
  document.write("Welcome to my site");
</script>