Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Introduction to Programming Basics Variables

Create a .js file in Google Chrome

Why does it feel like I'm the only one who isn't getting this? Help? I downloaded Text Mate but I don't know how to get it into my browser. . . .

2 Answers

lordcozycat
lordcozycat
11,940 Points

You have to create an HTML file, and either link or embed the javascript within it. You can link it like this:

<script src="learn.js" type="text/javascript"></script>

or simply put your code within the HTML like so:

<script>
    var example = "just testing";

    console.log(example);
</script>

When you want to open it in your browser, just open the HTML file with Google Chrome.

Michelle Cannito
Michelle Cannito
8,992 Points

You can right click a file with an .html extension and

Open with Google Chrome.

As the previous post stated, you can include your .js file by the src= part of the script tag. If the .js file is in a different directory, you will have to put the correct path name in the src= part.