-
-
Save jochemstoel/671a078cdc20aa81a8211a5eab961fce to your computer and use it in GitHub Desktop.
Random Rythem Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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