Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Introducing JavaScript Your First JavaScript Program

Robin Archer
Robin Archer
1,203 Points

Document.write method?

I am not familiar with the above method. I was taking MASH when the instructor began teaching on Java Script. So I began taking the Java Script Basics class which is where I am stuck. The quiz is asking me to code something that wasn't covered in the previous video. So I am wondering if I am in the wrong class. I guess I will go back to what I was originally taking. Thank you. I hope I explained this well enough as I am very new to coding anything anywhere with a computer.

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>

<body>
</body>

<document.write>
// <"Welcome to my site>"

</script>

</html>

4 Answers

David McGrath
David McGrath
5,207 Points

Robin Archer - I hope you haven't given up! I copied this from the "Code Challenge" and it works perfectly.

The only line that needed to be added was:

document.write("Welcome to my site");

Here is the entire script (HINT: copy and paste this into the code challenge and it will work):

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>

<body>
</body>

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

</html>
Robin Archer
Robin Archer
1,203 Points

Thank you! Thank you! so so much Dave.

Michelle

Hi,

I thought I would explain document.write in a little more detail. The teacher is asking you to use a built in JavaScript function which basically adds whatever you put in between the brackets to the page, in this case a string.

// When you see double quotes at the beginning of the line it means the line is a comment 
document.write("Welcome to my site");
David McGrath
David McGrath
5,207 Points

Try this:

<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>

<body>
  <script>
    // <"Welcome to my site">
    document.write("Welcome to my site");
  </script>
</body>
</html>
Robin Archer
Robin Archer
1,203 Points

Thank you for your help but I have written in yours as well as another answer and neither are correct. I give up. Would be great if the instructor answered this because I cannot go forward. I am stuck!

Robin Archer
Robin Archer
1,203 Points

Hi Dave, No I haven't given up...slightly aggravated lol...I will try this tomorrow. Thank you.