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 getting console error. not working

The Dom - have wriiten an expression console.log('hello from app.js'); I looked at all my HTLM and CSS all seems good the console does not find my doc app.js. path is good too. Please can you help me. N

Hi Nelson, could you please provide your code. A copy of the HTML and JavaScript would be really helpful in trying to solve your problem.

Here is HTLM

<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>RSVP App</title> <link href="https://fonts.googleapis.com/css?family=Courgette" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> </head> <body> <div class="wrapper"> <header> <h1>RSVP</h1> <p>A Treehouse App</p> <form id="registrar"> <input type="text" name="name" placeholder="Invite Someone"> <button type="submit" name="submit" value="submit">Submit</button> </form> </header> <div class="main"> <h2>Invitees</h2> <ul id="invitedList"></ul>
</div> </div> <script type="text/javascript" src="app.js"></script> </body> </html>

And here is my app.js

console.log('Hello from app.js');

Thank you Umesh

Hey, if you aren't aware, use the 'Markdown Cheatsheet' to see how to properly format any code that you post in the forums. It can really help a lot to have the code formatted correctly in many situations.

The code runs fine when I tried it, are you sure the app.js is in the right place? Do you get a 404 error in the console saying that it cannot be found?

Hi I used the cheat sheet as you call it. When i bring up the console on firefox and chrome and safari. This is what turns up...

CONSOLE: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. port-80-zveg4m2jg6.treehouse-app.com Use of document.createAttribute() is deprecated. Use element.setAttribute() instead. translator.js:2658:11 Use of setAttributeNode() is deprecated. Use setAttribute() instead. translator.js:2666:13

I really want to start learning but i cant move on yet. its been about 8hrs since i started my free trail service. Not sure if i'm happy now. But thanks for helping. N

2 Answers

Try adding <meta charset="utf-8"> between your <head> tags

Thank you good idea. I tried it and i think it helps but still not functioning properly.

Well, I tried running your code in my browser, and it worked, so it might be a problem in your browser. Also, how is your file-structure? Is your app.js in the same folder as index.html? Or is it in its own folder?