Update index.js

Added an attempt at a player state object - so that the player's output can be translated into a stored state, and that each state change will call a passed function.