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 trial

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

im confused on what I should be doing here and what it would look like if I did this correctly.

why is this not working?

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
  </head> Document.write(Mikes website);
<body>Document.write(Body paragraph);
</body>

<script>
Document.write(this is the scipt of mike);

</script>

</html>
Reuben Varzea
Reuben Varzea
23,182 Points

Hi there! Document.write() is going to expect whatever you pass it to be contained inside of quotes (single or double, your preference).

Also, any of your scripting needs to be done either within the <script> tags or inside of javascript file.

3 Answers

Peewee Silva
Peewee Silva
14,729 Points

Michael,

First, every time you use Javascript in a HTML file you need write your code inside the <script> tags.

Second, you need use quotes on the parameter received by the method, because it's a string, and when we write strings, we use then between quotes, singles or doubles quotes. Example: Document.write("this is the script of mike");

andren
andren
28,558 Points

There are quite a few reasons:

  1. All JavaScript code must go inside <script> tags, it can not be placed anywhere else in a HTML file.

  2. document has to be written in lowercase, JavaScript is case-sensitive, so the case matters.

  3. Strings, which is what is used to represent arbitrary text, has to be wrapped in quotes. It can't just stand on its own like you have done it in your code.

  4. The challenge asks you to write "Welcome to my site", that's the only message it asks you to write. It is not asking you to describe the structure of the webpage, or anything like that.

If you remove all of the code outside the <script> tag, fix the case of document, put quotes around your string and actually write the right message like this:

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

<body>
</body>

<script>
document.write("Welcome to my site"); // document is case sensitive, and text has to be wrapped in quotes

</script>

</html>

Then the code will work.

super helpful thank you!