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

add code inside the script

the question is add code inside the <script tags to write the words "Welcome to my site on to web page. When go to chk. answer its saying I didn't call document index?

Hi Mace,

I am stuck on this question. There are two files: a web page, index.html, and a JavaScript file, shout.js. To run any programming in the shout.js file, you first need to load it into the index.html file. Add the required HTML to load the external JavaScript file into the web page. Make sure to add your code inside the <body> of the page. index.html shout.js

1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <title>JavaScript Basics</title> 6 </head> 7 <body> 8 <script> <"src"> </script>; 9 </body> 10 </html>

4 Answers

-- --
-- --
12,382 Points

Hi Smita,

The exercise is actually asking you to write a code that displays "Welcome to my site" . A way to do this (covered in the video prior to the exercise) is by using document.write().

If you'd write "Welcome to my site" within the parenthesis after document.write, "Welcome to my site" will be displayed on your page.

The code would look like this:

document.write("Welcome to my site");

I hope this helps. :)

I put the answer on line 12, 14 the answer is still saying I didn't call document. write function. On line 12 it said to write the code their. I am not sure which line the code needs to be written on?

-- --
-- --
12,382 Points

Check your code for any errors. The code should be put between the <script> tags.

If you still cannot figure it out - could you share your code?

line 12// document.write ("Welcome to my site");

-- --
-- --
12,382 Points

So, the full document looks 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");

</script>

</html>

yes, thank you !