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) Storing and Tracking Information with Variables Working with Strings and Finding Help

Console.log not working

Hey, none of the exercises with console.log work for me:

here's my code from the "Working with Strings and Finding Help" workspace:

var passphrase = 'Open Sesame';
console.log(passphrase.length);

and here's what my console is telling me: Failed to load resource: the server responded with a status of 404 (Not Found) and it's pointing to script.js: 2

Aaron Martone
Aaron Martone
3,290 Points

Sounds as if you're not providing the correct path the your scripts.js file, thus it is not getting executed. Console is not part of JavaScript, but instead is an implementation of the browser itself. Check your spelling of the 'src' attribute. If the calling file is in the same directory, you can just reference the script name. If it's above, you'll have to use '../<folder>/scripts.js' in the 'src'. If it's below, you'll have to use '<folder>/scripts.js'. Notice that unless you are serving the files off a server, do not prefix the value in 'src' with '/' because there is no concept of "root" when serving locally (it will go to your root drive letter rather than a well-defined web root).

1 Answer

Hey Vikster,

How do you have your script.js file linked in your script tag?

Below are a few possible things to check:

<!-- If the file is not in a sub-directory -->
<script src="script.js"></script>
<!-- If the file is in a sub-directory -->
<script src="example/script.js"></script>

Essentially, this error is telling you that your script.js file cannot be found. This is why I suggest checking how your file is linked and if the file name is spelt correctly in the source attribute.