Skip to content

Instantly share code, notes, and snippets.

@jochemstoel
Forked from SethVandebrooke/randomRythem.js
Created January 18, 2021 21:22
Show Gist options
  • Save jochemstoel/671a078cdc20aa81a8211a5eab961fce to your computer and use it in GitHub Desktop.
Save jochemstoel/671a078cdc20aa81a8211a5eab961fce 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