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

Basic practice code; Chrome Console not working

My code is not working in Chrome. Using VS Code The HTML code:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge">

<script src="JavaScript.js"></script>
<title>Document</title>

</head> <body> <script src="JavaScript.js"></script> </body> <html>

And the Javascript:

var hello = "Hello";

console.write("Hello");

Mike Hatch
Mike Hatch
14,940 Points

Do you understand the error message that Google Console gives you?

var hello = "Hello";
console.write("Hello");

Uncaught TypeError: console.write is not a function  at <anonymous>:3:9

What that tells you is the code that needs to be fixed is "write". I've a feeling you meant "document.write" or "console.log" instead.

3 Answers

DOH'! Yeah, very bad over sight on my part, I forgot about the file/folder liking code. Once I put in the correct code "<script type ="text/javascript" src ="js/js.js"/>" Every thing works as it should. TA'DA!! Thanks again for the help :)

Mike Hatch
Mike Hatch
14,940 Points

You're welcome. It's a battle.

Steven Parker
Steven Parker
229,732 Points

As Mike pointed out, there's no "console.write" function. But there are "document.write" and "console.log" functions.

The choice depends on what you want to do. The "document.write" will put the output onto the browser page, and "console.log" will show it in the JavaScript console.

Thanks guys! I just got it, I was not connecting the external JS file correctly. Just a simple oversight, I believe. And the wrong placement of the document.write, and console.log parts. Ooopsie! :) Thanks again for the help. :) Steven Parker and Mike Hatch