Skip to content

Instantly share code, notes, and snippets.

@SethVandebrooke
Created November 2, 2018 14:06
Show Gist options
  • Save SethVandebrooke/30f1b21d1f181ab9b5190dbf841a4543 to your computer and use it in GitHub Desktop.
Save SethVandebrooke/30f1b21d1f181ab9b5190dbf841a4543 to your computer and use it in GitHub Desktop.
Random Rythem Generator
var generateRandomRythem = (weight) => {
let hit = "x", rythem = "--------".split("");
for (let i = 0; i < ( weight || 4 ); i++) {
rythem[Math.floor(Math.random()*rythem.length-1)] = "x";
}
return rythem.concat(rythem).join("");
}
console.log(generateRandomRythem(6));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment