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!
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
Eva Lerin
1,583 PointsIntroduction to Programming – my first program
Hello. I am a beginner and I would like you to help me. While studying the video Programming > Introduction to Programming > Basics > Writing Your Program I found some problems in the result of my exercise. This is what I did:
First I tried to repeat the exercise that the teacher, Jim, wrote in the video, that's to say I wrote the file index.html, then myScript.js, both in the same directory. Here are the codes:
-------- index. html ------------------------------
<! DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="keywords" content="">
<title> Introduction to Programming </title>
<script src="myscript.js"> </script>
</head>
<body>
<h1> Introduction to Programming </h1>
With <h2> JavaScript </h2>
</body>
</html>
-------- myscript.js ------------------------------
console.log ("Hello from MyScript.js");
I opened the index.html file with the Chrome browser and also I opened "Developers tools" to look for the expected result (the message "Hello from myscrpt.js)… But I got this message:
x Failed to load resource
What is the problem? Is it related to local web server? I noticed that Jim uses localhost in the browser, but I do not know what I can do to install a local server to work with Chrome. What to choose? Is there a guide to do it? I'm lost.
thanks for help in advance. Eva
5 Answers

Eva Lerin
1,583 PointsI finally found the answer! My two files were well written. I installed XAMPP on my computer. I stored my two files in htdocs \ MyProjects\ ... and the script worked: I coul read the message "Hello from MyScript.js"

seth123
Courses Plus Student 226 PointsWhen programming you need to remember the computer does EXACTLY and ONLY what you tell it to do.
I think this should be fixed if you remove the erroneous spaces in your code.
IE:
</ head>
should be
</head>
with NO space in it.
Fixed Code:
<! DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="keywords" content="">
<title> Introduction to Programming </title>
<script src="myscript.js"> </script>
</head>
<body>
<h1> Introduction to Programming </h1>
With <h2> JavaScript </h2>
</body>
</html>

Eva Lerin
1,583 PointsThanks Seth. I wrote </head> without spaces in my index.html. The program doesn't work.

J.T. Gralka
20,126 PointsEva,
I'm not sure what the source of your problem is... I copied and pasted your HTML and JavaScript into separate files, and (after removing the whitespace as SETH suggested) I was able to view the console.log()
output in Chrome. Are you sure that your index.html and myscript.js files are located in the same directory?
Best,
– J.

Eva Lerin
1,583 PointsHi J.
Both files are in the same directory (D:\sites\t4\index.html and D:\sites\t4\myscript.js) No spaces within tags. I don't have localhost
Thank you