A simple guessing game diving into Nodejs
August 23, 2014I first heard about Node.js (Nodejs) on the Changelog podcast in early 2010 and I have been looking at Nodejs now and then for the past four years and I have never really taken the time to sit down and use it. When I have taken the time I never found any good use case or an interesting project to build on top of Nodejs or maybe more importantly, why I should use Nodejs in the first place. Which problem does it solve? For me, none really. There is a lot to be said about Nodejs and projects that are built with Nodejs as a platform.
Nodejs is more popular than ever and in conjunction with poplar JavaScript frameworks like Angular, Ember, Knockout and Backbone it has become a force to be recon with for better and worse. So I thought that I would start exploring the possibilities Nodejs offer in all kinds of ways and what it can be used for and hopefully also make me a better JavaScript developer.
My first project is a version of the classic Guess the number game where you have to guess a number between 1 and 100. This game is a popular assignment when you start out learning a programming language so I thought it would be a great exercise to take on and it was! I had a lot of fun building this game and make it run on Nodejs. I did not dabble to deep in the readline module and relayed on console.log for output text to terminal and the readline question method to receive input from the user. I’m quite happy with the result and I will most likely polish and comment the code over the coming weeks.
You can find the game which I’ve named Guess100 in its current state over at my GitHub account. It is fully functional and I consider this a 1.0 release. If you want to improve it or has any kind of feedback or comments, don’t hesitate to make a pull request or start a discussion using the Disqus comments below. I have a few other projects lined up as I’ve taken on the learn BackboneJS as well and I think Nodejs will come in handy in many ways both as tool and as a server side technology.