Don't know what the gameState board is supposed to look like exactly, but I see you're calling split on key instead of pieceData. Regardless, it may be easier to debug scripts in a browser like FireFox using a separate js file to breakpoint and see where it's getting null versus console log.