Snake in JavaScript