CheckiO — 0: Need a Template for future solutions

Ben Merchant
3 min readMar 14, 2018

--

Credit: Wikipedia

Node.js was an easy choice, because implementing it is simple. It’s the most efficient way to launch a bit of JavaScript. There’s no need for the browser at all. I did include a bit of an http response in case someone knows even less about node than I do and wants to dabble a little bit.

Speaking of knowing less, as it turns out, all of my practice with Node thus far has been using the Express framework. As such, the most simple module and functions needed to start a basic Node server were unknown to me. Express buries them, rather, it builds on top of them so you never see them.

Basically, I’ve been learning how to install drywall, but I’ve never even seen anyone pour a concrete foundation.

Enter a well-thought-out, quick tutorial . After a few minutes, I was able to have a very simple server template up and running. Check it out here.

Where it says, “// type solution here”, I simply have to copy and paste my solution from the in-browser CheckiO code editor, remove two lines of code, and run the app from the console.

Remove this code when copy/pasting from CheckiO editor

I’m not sure what that global variable is or what they use it for, but we don’t need it. What we do need is the code inside that if statement. Those are the deepEqual() functions from Node’s assert module. These functions test for equality between the first parameter and the second. The third parameter is a message to be logged to the console in the event that the first two parameters aren’t equal.

In the first challenge (and presumably the ones to follow) we pass a function into the deepEqual() function as a parameter. Our solution function returns a variable of our choosing. The goal is to get it to return something that matches the second parameter.

Why the Extra Work?

CheckiO didn’t do a spectacular job of explaining what was happening inside their code editor. For instance, I had no idea what assert.deepEqual() was, nor did I know that it was a function from a Node module. I thought it was just a regular JavaScript function. This lends some hindsight value to the decision to create a Node app for each solution.

So, right off the bat, I’m learning more about Node. Of course, one could infer what was going on, but I like to know how something works and why it’s necessary.

Concurrently, from what I understand so far, Node is the simplest way to just run some JavaScript. We run it right in the console, and see our results there as well. No need to even open a browser. Like I said above, there is some http-ing going on, but that was also for my own edification as, until now, I did not know how very little code you needed to get a Node server running.

Time For Solutions

I have finished porting my solution into the template and will post the story as soon as I write it up later today. This journey has already proved itself fruitful.

--

--