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 Basics (Retired) Introducing JavaScript Where Does JavaScript Go?

Can't get my second alert to appear

INDEX CODE: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>JavaScript Basics</title> <script> alert("Here's another message from Treehouse"); </script> </head> <body> <div class="container"> <h1>Where to place your JavaScript code.</h1> </div> <script src="script.js"></script> </body> </html>

SCRIPT.JS CODE: alert("Hey, you're back for more?");

I can't seem to get the second alert that says "Hey you're back for more" to pop up?

Please help

John Erickson
seal-mask
.a{fill-rule:evenodd;}techdegree
John Erickson
Full Stack JavaScript Techdegree Student 3,916 Points

Good afternoon Chandni,

What you've provided is your HTML, however what your asking is regarding your javaScript file. Any chance can you repost w/ your javaScript?

Although I'm new to javaScript, your syntax looks good. I also tried it myself using the developer tools and it works.

I also found this which may help: http://www.w3schools.com/jsref/met_win_alert.asp

Benjamin Barslev Nielsen
Benjamin Barslev Nielsen
18,958 Points

The code works fine for me. It is most likely that it doesn't find your script.js file. Is script.js placed in the same folder as the index.html? When running in the browser, do you see any errors in the console?

John Erickson
seal-mask
.a{fill-rule:evenodd;}techdegree
John Erickson
Full Stack JavaScript Techdegree Student 3,916 Points

I think I may have figured out your issue. In your HTML/head tag you have placed a script tag, but don't provide the src attribute. When watching the video go to time stamp 3:11:

<script src="scripts.js"></script>

This should correct your problem.

I got it -->

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="css/main.css"> <title>JavaScript Basics</title> <script> alert("Here's another message from Treehouse"); </script> </head> <body> <div class="container"> <h1>Where to place your JavaScript code.</h1> </div> <script src="scriptS****.js"></script> </body> </html>

Steven Parker
Steven Parker
231,271 Points

The name of your file is "scriptS****.js":question:   How odd:exclamation:

Your syntax in both the JavaScript and the HTML looks fine. Try checking for typographical errors. Does the name of the script file actually match the name you put in the src attribute exactly? Make sure spelling and case match exactly then try again. Usually small errors like that break our code and take hours to fix because we often have trouble finding our own typos.

2 Answers

Your syntax in both the JavaScript and the HTML looks fine. Try checking for typographical errors. Does the name of the script file actually match the name you put in the src attribute exactly? Make sure spelling and case match exactly then try again. Usually small errors like that break our code and take hours to fix because we often have trouble finding our own typos.

Piyush Patel
Piyush Patel
17,253 Points

Yes, there might be simple errors like typing the file name wrong or linking the files incorrectly in the directory path.