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 trialAshley Abid
863 PointsI'm sorry, everyone, I'm such a newbie. Can anyone tell me what I'm doing wrong? I tried doing what I saw in the video.
I typed in both the alert and document.write commands but the preview still ends up showing nothing. :(
<!DOCTYPE HTML>
<html>
document.write("<h1>Welcome to my site</h1>");
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
</body>
<script>
// alert("Welcome to my site");
</script>
</html>
1 Answer
jacobproffer
24,604 PointsHey Ashley,
If you take a look, a script tag is provided below the body at the start of the challenge. You're going to want to write all of your JavaScript code inside of the script tag (For this challenge):
<script>
// Write your code here.
document.write("This is an example."); //Write to the document
alert("This is an example"); //Alert the user
</script>
Currently, you are trying to write to the document below the opening html tag, which is why you're not seeing anything in the preview.
Best,
Jacob
Ashley Abid
863 PointsAshley Abid
863 PointsThank you so much, Jacob!!! It's my first time officially coding in the Javascript language so completing my first challenge,with your help,was really nice. :D