Chess implementation in JavaScript