Writing snake in Javascript.