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 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

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.