JS in Chrome

How come I copy and paste the javascript code into a a text editor, save as html, then try to open n Chrome. All it does is spit back the code without running it. Does javascript only run in Codecademy?

JS code needs to be saved as .js
If you are putting it in an HTML file then you need HTML skeleton built and in the body add

<script type="text/javascript">
//js code goes here