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

G. Silva
G. Silva
4,341 Points

My html page is not loading my java script file. error msg:Uncaught SyntaxError: Unexpected end of input

<!DOCTYPE html>
<html lang="en">
    <head>
    <title> Introduction to Programming</title>
    <style>
        html{
            background: #FAFAFA;
            font-family: sans-serif;
        }
    </style>    
    </head>
    <script>src="myfirstscript.js"></script>
    <body>
        <h1> Introduction to Programming</h1>
        <h2>with JavaScript</h2>
    </body>
</html>

myfirstscript.js

console.log("Hello from myfirstscript.js");
console.log("Hello again!");
alert("Hello" + prompt("What is your name?"))

1 Answer

Joe Bruno
Joe Bruno
35,909 Points

You need a semicolon after your last statement.

 alert("Hello" + prompt("What is your name?"));

Also, on your script src statement, it should be:

 <script src="myfirstscript.js"></script>
G. Silva
G. Silva
4,341 Points

Thank you Joe, It solved the problems I was having.