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 trialDaniel Holmes
2,765 Pointsproblem
what did I do wrong
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script>
<script>'Begin Program'</script>
document.write("Welcome to JavaScript Basics");
</script>
</body>
</html>
3 Answers
Taylor Michel
15,634 PointsYour document.write() statement is outside of your <script>
tags.
Also you forgot your console.log() statement for "Begin Program".
Your code should look something like this...
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script>
console.log("Begin Program");
document.write("Welcome to JavaScript Basics");
</script>
</body>
</html>
Bob Sutherton
20,160 PointsDaniel Holmes, as shown above, you do not want to have the extra set of script tags. You should only wrap your JavaScript code in one set of script tags. Those tags let the browser know that it is dealing with some code, in this case JavaScript.
In JavaScript there are no markup tags or headings like in HTML. Instead, comments are used to demarcate different places in the code so that it is easier for you or another programmer to follow what is going on.
Console.log() is used to log messages is to your browser's console, which can be accessed with ctrl+shift+j on a windows computer like I use. On a mac, I think it is cmd+option+j or something like that.
So one of the things console.log() allows you to do is to check whether you have arrived at a certain point in your script.
Jacob Mishkin
23,118 PointsDaniel Holmes I see your having trouble with your element tags. I would advise you before you go further learning JavaScript that you have a solid foundation of element tags. lets quickly break down this process:
just like in HTML tags, the script tag works the same way. When writing JavaScript inline and or linking to an JS file, all JS needs to be Inside the tags, just like HTML. see below:
<div>
<P>Hello World!</p>
</div>
<script>
alert("Hello World!");
</script>
this is the structure for elements. I hope this helps. If you have any questions please feel free to ask us.