3 ms·
Here's a console command you can run to increase the snake length immediately, and thus the difficulty: (() => { let count = 50; const delay = 100; const in
by re 9mo ago
Here's a console command you can run to increase the snake length immediately, and thus the difficulty:
(() => { let count = 50; const delay = 100; const interval = setInterval(() => { addSnakeNode(); if (--count <= 0) clearInterval(interval); }, delay);})()
- londons_explore 9mo agoWhy wrap in a lambda?
- tinyhitman 9mo agoCould be to allow use of local variables that do not leak into the scope this code is executed in. That's what I use this pattern for.
- crdrost 9mo agopro tip: no longer necessary { let count = 50; const interval = setInterval(() => { addSnakeNode(); if (--count <= 0) clearInterval(interval); }, 100) }
- londons_explore 9mo agoAnd polluting the global variable namespace hardly matters when using the console.
- re 9mo agoBecause I learned JS before ECMAScript 6 was widely supported by browsers and haven't written a ton of it targeting modern browsers. You're right that it's unnecessary.