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 trialSneha Mondal
219 PointsAdd code inside the <script> tags to write the words "Welcome to my site" onto the web page.
I wrote the below script: document.write("<h1>Welcome to my site</h1>"); But it is showing the error " you didn't call document.write function." Please help.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
</body>
<document.write("<h1>Welcome to my site</h1>");>
// Write your code here.
</script>
</html>
Marc Maninang
1,147 PointsIn order for Javascript to run in HTML, it needs to be wrapped in script tags: <script> </script>
Looks like you're missing the opening script tag.
1 Answer
Steven Parker
231,269 PointsRight code, wrong place!
- your code needs to go between the script tags
- it looks like you replaced the first tag with your code instead
- a blank line was left after the comment where you should put your code
- never alter code given in a challenge unless the instructions specifically say to
<script>
// Write your code here.
document.write("<h1>Welcome to my site</h1>");
</script>
Sushant Kumar
Courses Plus Student 3,555 PointsSushant Kumar
Courses Plus Student 3,555 PointsHi Sneha, Please write code in <script> tag, and also try to write script in Body. document.write should not be in corner bracket "<>".
Code should be: