Created
November 2, 2018 14:06
-
-
Save SethVandebrooke/30f1b21d1f181ab9b5190dbf841a4543 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