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

Drew Van Roekel
Drew Van Roekel
463 Points

I'm extremely new to programming and I'm having some trouble with this question...

I'm having some trouble understanding the basics. Please help.

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

<body>
</body>

<script>
<"Welcome to my site">;

</script>

</html>
Drew Van Roekel
Drew Van Roekel
463 Points

Figured it out. Thanks all :D

2 Answers

andren
andren
28,558 Points

In the video preceding this challenge you were introduced to two functions, alert and document.write. Both of those functions performs some kind of action. The alert function creates a popup containing the string (text) you pass to it and the document.write function writes whatever string you provide it to the webpage itself.

Since the challenge asks you to write the words to the webpage the function you have to use is document.write. The way you call and pass data into a function is by placing parentheses after the function name and then the value within those parentheses.

So if I wanted to write the message "Hello World!" to the webpage the code would look like this:

document.write("Hello World!");

The code you have to place within the script tags is pretty much identical, you just have to change the message from "Hello World!" to "Welcome to my site".

Edit: I see my response was a bit late, oh well as long as you managed to figure it out that's all that matters. I'll leave this response up in case others ends up struggling with the same challenge.

Thomas Fildes
Thomas Fildes
22,687 Points

Hi Drew,

Don't be afraid of not knowing something. Everyone starts off somewhere and have been in the same position as you :)

I used the following code below to pass this challenge:

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

<body>
</body>

<script>
// Write your code here.
  document.write("Welcome to my site");

</script>

</html>

Hope this helps! Happy Coding!!!

Keep it up :D