JavaScript JavaScript Basics Hello, JavaScript! Add JavaScript to HTML

William Cook
William Cook
688 Points

Workspace not working correctly.

I'm following this step by step and it is not working correctly in the video index.html is not showing up in the correct order or correct folder in the workspace.

1 Answer

Peter Vann
MOD
Peter Vann
Treehouse Moderator 31,785 Points

Hi William!

I'd have to see your code and your workspace folder tree to really know what is going on.

But, for starters, make sure that your workspace "JavaScript Basics..." folder contains a css folder, index.html, and a js folder.

The css folder should contain the style.css file and the js folder should contain the files preview.js, script.js and app.js (if you made an app.js file).

If that's the case and you typed your code just as Guil did, you should be OK.

I did create an app.js file, so my HTML code looks like this:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>JavaScript Basics</title>
    <link href="css/style.css" rel="stylesheet">
    <script src="js/script.js"></script>
  </head>
  <body>
    <main>
      <h1>Hello, JavaScript!</h1>
    </main>
    <script src="js/app.js"></script>
  </body>
</html>

My script.js code:

alert("Hey, you're back for more?");

My app.js code:

alert("Another message from inside index.html");

I hope that helps.

Stay safe and happy coding!