How to practice coding when offline?

Hey Campers,

I really want to solve the algorithm challenges in my own local code editor first, so that I can paste them into freecodecamp later and complete the challenge.

Another reason for this is because I will be travelling for a couple of weeks and internet will not be available often, so then I can at least continue my coding and practice offline.

Can anybody help me with setting up, for example, the Brackets editor so that I can practice java with the help of my chrome dev. console? Are there any tutorials out there?

Thanks

2 Likes

I’m not quite sure I understand the question. You should be able to write the code in brackets and use the dev console the same way you would with any other text editor, by opening your root web page (usually index.html). Is it that you’re looking for LiveReload functionality? (Also, I’m assuming that you’re referring to JavaScript rather than Java?)

If you’re simply looking for how to test the algorithms, I made a simple pen which you can copy into brackets (make sure to use the correct HTML boilerplate code). This simply outputs the value into a text field and allows you to view console.log() statements in Chrome’s dev console. (Apologies if this isn’t what you’re asking)

It wouldn’t be difficult - you’d want to install NodeJS, which would run your JavaScript code, and then you’d be set. You can write out your algorithms in Brackets, save the file locally, and then run it like so

node my_file.js

You’d see the output of your calls to console.log() in the terminal. The problem, though, is that when you run your solutions in the browser, it’s using some pre-defined test data that it uses to make sure you’re passing each of the requirements. So, you’d need access to the internet in order to run the tests, fail them, and get the test input for you to enter manually. In short, it is possible, but quite difficult right now. What I would suggest doing instead is getting a good book on web development and bringing that with you. Something practical, like Head First JavaScript, would be ideal at your stage of learning, I think, but there are doubtless other options.

I have solved this problem by getting a freedompop hotspot. I can access the net when at doctor’s appointments, etc, and work on free code camp. By using it only for FCC and a few other things, I can stick with the free plan.

JavaTheNutt is right on the money. Open your browser of choice, I use Chromium. Open your developer tools or hit ctrl-shft-I . click on the console tab, then copy and paste your code/js functions into the console and hit enter. After that you can call your function anytime within the console by typing the functions name. Copying and pasting the code seems to work best for me, otherwise we seem to be stuck writing all code on one line. You’ll see what I mean when you give it a try.

That is the easiest way I can think of using the browser.

Another very simple way to do this is use your editor of choice… You’ll create 2 files in a folder:

  1. “index.html” with standard boilerplate (if you type “html” and hit tab, it might automatically write it for you).
  2. “app.js” or whatever name you like. In your html file, link the file with a script tag either in the <head> or at the bottom of <body>. It should look like this: <script type="text/javascript" src="./app.js"></script>. You write your code in this file, and you can either have the solution print to the screen with document.write(answer); (not preferred in real coding situations), or make use of console.log(answer); and view it in the console (as described above). Alternatively, you could just write all of your javascript in the <script> tags in the html file.

If you double-click the index.html file, it will open locally in your browser. Open the console under dev tools as described above to view. After any changes you make in the file(s), save and then refresh the browser. When you paste your answer back to FCC, remember to switch the console.log() back to the appropriate return statement.

If you use firefox, you may want to download firebug plugin, it has nice console, debugger and other things.

Thanks for the help guys!

Ive created a html and downloaded bootstrap and jquery too, so I can practice offline wherever I am.