The Sudoku Challenge

I’ve challenged myself to create a game of Sudoku. Why you ask? Because it is broad enough to exercise all of the different Javascript skills I want to work on, while not being so complex as to be a big time sink on any one area.

In computer programming, it is not often the case that the challenge you end up with is the same as you conceived beforehand. Three days into it, I’m happy to say it is exactly as I had hoped for.

The Sudoku puzzle, like most web apps, breaks apart nicely into the MVC model. I wrote the model first and it was pretty easy. I made a two dimensional array to represent the squares, and a square object to fill each square. I hit a major snag when my outputs showed everything as working as it should, but then when I tried to output the board all at once, every square was filled with the value of the last square! It turned out at that point I didn’t understand closures as well as I thought I did, and instead of creating the 81 squares of the sudoku board, I was creating only one and changing it’s value. It was a pain to debug, but I came out of it really understanding Javascript closures.Read More