Created
June 5, 2018 18:01
-
-
Save bijeebuss/e62ebdbe318221333b7d62d5a3846b0f to your computer and use it in GitHub Desktop.
This file contains 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
const vowels = ['A', 'E', 'I', 'O', 'U']; | |
const constenants = ['B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'] | |
function randomInt(min: number, max: number): number { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
function randomConstenant(): string { | |
return constenants[randomInt(0, 20)]; | |
} | |
function randomVowel(): string { | |
return vowels[randomInt(0, 4)]; | |
} | |
function sentenceCreator(): string { | |
const words = randomInt(2, 5) | |
let sentence = ''; | |
for(let i = 0; i < words; i++) { | |
let word = ''; | |
const numOfLetters = randomInt(3, 10); | |
for(let j = 0; j < numOfLetters; j++) { | |
word += j % 2 == 0 ? randomConstenant() : randomVowel(); | |
} | |
sentence += word + ' '; | |
} | |
return sentence; | |
} | |
console.log(sentenceCreator()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment