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

what is the problem in my code?

document.write("Welcome to JavaScript");

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>
// Write your code here.
alert("Hello");
  document.write("Welcome to JavaScript");
  alert("Nice to see you");
</script>

</html>

1 Answer

Your code is technically correct, but it isn't what the challenge asked for.

The challenge asked you only to display "Welcome to my site" on the browser and never asked you to log anything to the console, alert anything, or display "Welcome to JavaScript" on the page.

Remember that code challenges are very picky and won't let you pass if you don't do exactly what you ask for. In this case it only asked for you to document.write() "Welcome to my site", but you did all of this mumbo-jumbo it didn't ask for.

All you need to write between the <script> and the </script> is this:

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

Also, I just noticed that you wrote some extra code that's not in the <script></script>. You only need to write JavaScript in the <script></script>!

~Alex