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 Loops, Arrays and Objects Tracking Data Using Objects Using `for in` to Loop Through an Object's Properties

Mirali Mirzayev
Mirali Mirzayev
1,980 Points

HTML Set up

Hello Everyone could you please help me out with my HTML syntax in Atom:
<!DOCTYPE html> <html> <body> <script src = "helloworld.js"></script> <p></p> </body> </html>

JavaScript is not printing out into the screen because of something wrong here.

Thank you in advance.

Justinas Vebra
Justinas Vebra
1,053 Points

This is the correct HTML to begin with:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="css/main.css">
  <title>Title</title>
 </head>
<body>
   <script src="helloworld.js"></script> 
</body>
</html>

I assume you wanted to print out some text with the help of JavaScript, so just add this part to the helloworld.js file:

document.write("Hello, World!");

Again, the JavaScript part is shown because of the assumption. Let me know if this is helpful or more information is needed.

1 Answer

Could be a simple problem of not referring correctly to where your javascript file is located. I always put my javascript files in a JS folder. Assuming you're working in the root folder of your project the pathing would be <script src = "js/helloworld.js"> or if you're in another folder and want to move up a directory first you could put down <script src = "../js/helloworld.js">.

If it's a problem with actual code please put down the code form your helloworld.js