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 trialRobin Archer
1,203 PointsDocument.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.
<!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
5,207 PointsRobin 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>
Dean Gray
12,487 PointsHi,
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
5,207 PointsTry 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
1,203 PointsThank 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
1,203 PointsHi Dave, No I haven't given up...slightly aggravated lol...I will try this tomorrow. Thank you.
Robin Archer
1,203 PointsRobin Archer
1,203 PointsThank you! Thank you! so so much Dave.
Michelle