Skip to content

Instantly share code, notes, and snippets.

@coderbyheart
Last active September 22, 2020 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderbyheart/578110b662e271a692954c292c60bb3a to your computer and use it in GitHub Desktop.
Save coderbyheart/578110b662e271a692954c292c60bb3a to your computer and use it in GitHub Desktop.
heads.js
const dirs = ["UP", "DOWN", "LEFT", "RIGHT"];
const max = 20;
const interval = 2500;
let i = 0;
console.time("heads");
const r = setInterval(() => {
const n = Math.floor(Math.random() * dirs.length);
console.timeLog("heads", ++i, dirs[n]);
if (i >= max) clearInterval(r);
}, interval);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment