This forum is now read-only. Please use our new forums at discuss.codecademy.com.

414 points
F17708e7d8bd1cb8f4c4a309134d0b27?s=140&d=retro
Submitted by
Farzam TN
about 4 years ago

How can I run JavaScript programs in my computer offline?!

Can somebody please explain to me that where can I download the terminal and the editor and run and edit codes in my PC offline without the codecademy website? (for example like python command)
Thanks !


0 votes

permalink

Hi, Farzam,

If you have a decent text editor (eg. Notepad++) and a browser, you have everything you need to run JavaScript offline. One other tool that will come in handly is node.js. It permits us to save .js files on our local volume and run them from the command line.

(In Windows, open the Start menu and in the search field, type cmd. This will open the command window.)

node myScript.js

That aside, we don't NEED node.js, it's just handy and once we advance our skills to be able to actually use all its power, a very powerful tool.

Your browser will have a Developer Tools section that includes a JavaScript Console. In Chrome this is Ctrl+Shift+J (or look in the tools menu). Other browsers will use different hot keys and their console will be slightly different, but no matter. They are all pretty much the same. A command line interpreter, a command line and a terminal display.

All we need to do is write our script, and when ready to test it, copy the entire script and paste it into the command line and Enter. The console is not an editor so we cannot write multi-line code directly to it. We can write line by line, but rather than Enter, use Shift+Enter to drop to a new line. Try typing this in line by line (ignore comments)...

for (var i = 0; i < 10; i++){ // Shift+Enter
    console.log(i);           // Shift+Enter
}                             // Enter

As soon as you press the last Enter the code will execute.

We can also merge script in an HTML document but we can talk about that later. Remember to save your work.

It's also worth noting that once we enter code it remains in memory for the duration of the session. This is handy since it lets us enter complete functions and stores them so we can call them repeatedly. If we need to edit one function, we only need to re-enter that function (edited), not the whole program.

This is useful when we find ourselves using the same piece of code often. We can compose a small library of useful functions, paste them into the command line at the start of the session and have them as TSR's during the session.

TSR => Terminate and Stay Resident

9007 points
5958b8ebe12813a2a3000034_980106998
Submitted by
Roy
about 4 years ago


0 votes

permalink

Thanks for the great information and details. I just installed the node.js however i don't know how to use it well. The chrome's JS terminal seems to work just fine but I think there is something wrong with the firefox terminal. But thank you anyway!

414 points
F17708e7d8bd1cb8f4c4a309134d0b27?s=140&d=retro
Submitted by
Farzam TN
about 4 years ago