Chitharanjan Das's Blog

Read this first

Javascript Weekly Challenge #1

Starting today, I plan on coming out with a new JavaScript challenge every week. These problems might look leisurely and pointless at the outset, but solving them should require intermediate-level language skills. Answers will be posted at the end of the week, one day before the next challenge comes out. Cheers!

How would you make the following work?

add(2, 5); // returns 7

add(2)(5); // returns 7

add(2)(5)(1, 3)(4); // returns 15

add(2)(5)(1, 3)(4)(1, 1, 2)(1)()(1, 1); // returns 22

DISCLAIMER I came across this problem while going through the very popular Front-end Job Interview Questions repo on Github. It caught my attention since I’d recently seen something similar in Angus Croll’s If Hemingway Wrote Javascript.


All queries and solutions (fiddles/pastebins) may be sent in via e-mail. Solutions may also be submitted by forking the Github repo.

Continue reading →


If Arundhati Roy wrote JavaScript

Angus Croll’s If Hemingway Wrote JavaScript is a beautifully illustrated book full of code snippets that are rich in their use of fundamental JavaScript abstractions and modern programming patterns. Born out of equal love for both literature and JavaScript, this book is a whirlwind tour through imaginary GitHub repos belonging to some of the most celebrated wordsmiths of our time, from Shakespeare to JD Salinger to Tupac, including of course Ernest Hemingway.

Authors featured in If Hemingway Wrote JavaScript



No Starch Press has been publishing many thoroughly readable programming books over the years, including the much-acclaimed Eloquent JavaScript and Learn You Some Erlang for Great Good! Although If Hemingway has a far more leisurely style than the other books, it is by no means a lesser spectacle of code craftsmanship. Reading some of the examples requires (or, like in my case, inspires) a proper understanding of scoping...

Continue reading →


Prison Break: A Simple Counting Problem

Imagine a prison having 36 cells arranged like the squares in a 6-by-6 grid. All adjacent cells have doors between them; doors that you can open. You, the prisoner in the top-left corner cell, are told that you can have your freedom if you can find your way to the diagonally opposite corner cell, after passing through each other cell exactly once.

An empty prison map


Can you figure such a way out of the prison?

If this seems to be taking you an embarrassingly long time, feel free to click here for the solution

View →