Saturday, February 20, 2016

How to easily pass Free Code Camp's Algorithm Scripting challenges - OR - Why you shouldn't use the browser challenges

New coaching testimonial coming on Sunday!

While researching Free Code Camp ( It changes quickly so I wanted to make sure what I was saying was up to date ), I found out some issues with the browser based scripting challenges that really bothers me.  As of last year, I was able to use the Ramda.js library in the browser challenges online.

I tried every way to call/require the Ramda.js or Lodash.js libraries without any success.  I searched online for 30 minutes trying to figure out how to use Ramda.js with the online coding challenges and couldn't find any information.  I personally think the Ramda.js library was removed.  Either way, it should not be this hard to figure out how to use a Javascript library like Lodash or Ramda with the challenges.

I know as of August last year (2015) Quincy Larson said on Quora that you could use Ramda and Lodash in the online challenges:

I also can show you how I used Ramda.js last year with Free Code Camp online challenges:

I hope I am wrong, I hope someone will clear up this issue and show me how to use Ramda.js with Free Code Camp, without it, I don't think you should use the online editor.  I recommend copying and pasting the challenge into a text editor and then using Lodash or Ramda libraries.

The article below is how I used to easily solve the Free Code Camp challenges, hopefully, this will help you solve the challenges easier or switch over to Ruby :-)

This was my original post as of a month ago.

I've been asked by many people to write how to pass the Free Code Camp scripting challenges.  Here goes:

NOTE:  I love Free Code Camp's Algorithm challenges and recommend them to my coaching clients all the time.

There are several reasons why Free Code Camp's challenges are hard:

  • When you run your code you don't get to see the output ( sometimes you get some sort of output, put it's not the same as running it in a REPL on your terminal ).
  • You can use the Ramda.js Library but it is not advertised on the site at all.
  • Nowhere does it tell you on Free Code Camp how to call the Ramda.js Library.
  • Why would you have a Javascript library built into the Bonfire Algorithm challenges but not tell beginners how to call a Library?
  • Using built-in methods is frowned upon in the community, using nested loops is considered better and more 'vanilla Javascript'.

8 steps to solve them easily

Here's how to get around these issues:

(1)  As soon as you get to Bonfire Algorithm Challenge, the very first thing to do is click on the 'Run tests' button.

You want to find out all of the edge cases that you need to solve with your code. Leave this browser window open to reference.

(2)  Next copy and paste the Bonfire Algorithm Challenge code into your text editor.  This is where you will actually work on solving the challenge.  Once you solve one of the cases you need to solve for the challenge, paste it into the browser and run the tests.  Using this approach you will eventually solve the entire challenge.

(3)  Look at the 'helpful links', they are basically the methods you will be using to solve the challenge.  NOTE:  This is the best new feature that Free Code Camp has added lately, this is exactly what I used to do in the past, look for a Javascript method that could solve the challenge first before doing anything else.

(4)  Next look at Ramda.js Docs and see if you can find a built-in method that you can use to solve or partially solve the challenge.

(5)  Make sure you test that you are requiring and using the Ramda.js library correctly on your local machine.  First install Ramda with NPM, if you don't have NPM you will need to install Node.js.  After installing Node and Ramda, open the REPL from the command line and make sure you can access the Ramda methods.

(6)  Always be checking your codes output.  Use 'console.log' all through your code if you don't know what something is doing or want to see output for a particular piece of code.

(7)  Always avoid using multiple nested loops if possible as your solution.  No company will ever want you writing code like that in production.  Ignore people who say to learn that way first and then use methods.  Everytime you use a loop you add another layer of complexity to your code, use the built-in methods as much as possible.

(8)  First try to solve the challenge anyway possible, if you get it solved, then see if you can clean up your code or solve the challenge in a cleaner way.  Don't strive for perfect when you are just starting out.  Focus on completion and solving the challenge first, pretty second.

Learn to use your REPL and local machine instead of relying on the Free Code Camp online editor.  Focus on the output of your program and try to slowly solve one piece of the challenge at a time.  Never get discouraged, if it takes you 3 days to solve a challenge that's okay, you will have learned a lot about coding in those 3 days.  Don't worry if someone else can solve a challenge in 3 minutes, they have probably seen similar challenges before.

Keep coding peeps, you can do this!!!