Javascript Implemention of Snake