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! While you're at it, check out some resources Treehouse students have shared here.

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

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops For Loops

Michael Williams
PLUS
Michael Williams
Courses Plus Student 8,059 Points

I keep getting this error, "Failed to load script.js:1 resource: the server responded with a status of 404 (Not Found)."

I get the aforementioned error in the console, but I can't figure out what's going on for the life of me. Anyone catch my mistake?

var html = " "; 

for ( var i = 1; i <= 10; i += 1 ) {
  html += "<div>" + i + "</div>"; 
}
document.write(html);
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Circles</title>
  <link rel="stylesheet" href="css/styles.css">
</head>
<body id="color">
<script src = "js/script.js"></script>
</body>
</html>

2 Answers

Hi Michael.

<!- your code ->
<script src = "js/script.js"></script>

<!- should be ->
<script src="js/script.js"></script>

As you see in your code you added a space after 'src' and after '=' sign.

It's a syntax error -> there are no spaces to be present and it says it can't load it because it can't find it - but it's just a syntax error.

Hope this helps.

Michael Williams
Michael Williams
Courses Plus Student 8,059 Points

Thank you Nejc. I didn't realize that whitespace mattered in HTML.

Ali Abbas
Ali Abbas
2,097 Points

I'm honestly surprised by this because I have space in my 'src' and '=', but my code still ran. I thought space didn't matter in coding languages and if it does, then I'm surprised my one works. Weird :-/

Weirdly my has no spaces but has the same error!

port-80-4q2qxiwckv.treehouse-app.com/:9 GET http://port-80-4q2qxiwckv.treehouse-app.com/js/script.js net::ERR_ABORTED 404 (Not Found)

'''<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Circles</title> <link rel="stylesheet" href="css/styles.css"> </head> <body id="color"> <script src="/js/script.js"></script> </body> </html> '''

Hi Mersad.

Your problem is that the script could not be found because you have a / in your path which means look at the root of your file system.

// This is your code
<script src="/js/script.js"></script>

//Should be:
<script src="js/script.js"></script>

I hope this helps.

Enjoy JS :D