Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

melissa brown
melissa brown
4,670 Points

alert isnt working

my code isnt working cant see that it is any different to the code in the video

~alert("Hello from Treehouse"); document.write("<h1>Welcome</h1>"); alert("thanks for visiting");~

3 Answers

Hugo Paz
Hugo Paz
15,622 Points

Hi melissa,

Can you please post your full code and what you want to achieve?

melissa brown
melissa brown
4,670 Points

ive added the index.html file from the video downloads. but im a bit confused do we always need html to do js? now my document says can you get the javascript to work and instead of welcome. Not sure sure what should be in the html file it doesnt show it in the video.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="css/main.css">
  <title>What's wrong with this script?</title>
 </head>
<body>
  <div class="container">
  <h1>Can you get the JavaScript to work?</h1>
  <script src="scripts.js"></script>
  </div>
</body>
</html>
alert("Hello from Treehouse");
document.write("<h1>Welcome</h1>");
alert("thanks for visiting");
Hugo Paz
Hugo Paz
15,622 Points

I edited your post so the code is legible, please uset edit post so you can see how I did it.

Here is the simple way to do it, create a folder - you can name it whatever you want.

Inside put 2 files, index.html and scripts.js,

In the index.html file paste the first code (the html).

In the scripts.js file paste the second code (the javascript).

Open the index.html file in your browser.

melissa brown
melissa brown
4,670 Points

its ok i figured it out thanks