Skip to content

Instantly share code, notes, and snippets.

@coderbyheart
Last active Sep 22, 2020
Embed
What would you like to do?
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