Skip to content

Instantly share code, notes, and snippets.

@moflo
Created April 13, 2017 16:55
Show Gist options
  • Save moflo/cc2aab67afadd1704726b20ab6ebcf0d to your computer and use it in GitHub Desktop.
Save moflo/cc2aab67afadd1704726b20ab6ebcf0d to your computer and use it in GitHub Desktop.
JS ES6 Lorem Ipsum Random String Generator
var randomInt = (min,max) => { return Math.floor(Math.random() * (max - min + 1) + min) }
var loremString = (max) => {
let words = ['ad', 'adipisicing', 'aliqua', 'aliquip', 'amet', 'anim', 'aute', 'cillum', 'commodo', 'consectetur', 'consequat', 'culpa', 'cupidatat', 'deserunt', 'do', 'dolor', 'dolore', 'duis', 'ea', 'eiusmod', 'elit', 'enim', 'esse', 'est', 'et', 'eu', 'ex', 'excepteur', 'exercitation', 'fugiat', 'id', 'in', 'incididunt', 'ipsum', 'irure', 'labore', 'laboris', 'laborum', 'Lorem', 'magna', 'minim', 'mollit', 'nisi', 'non', 'nostrud', 'nulla', 'occaecat', 'officia', 'pariatur', 'proident', 'qui', 'quis', 'reprehenderit', 'sint', 'sit', 'sunt', 'tempor', 'ullamco', 'ut', 'velit', 'veniam', 'voluptate' ]
var sentence = ''
var count = max
while (count > 0) {
let i = randomInt(0,words.length)
let word = words[i]
sentence = count == max ? word : sentence+' '+word
count = count - 1
}
if (sentence.length) {
sentence = sentence.slice(1);
sentence = sentence.charAt(0).toUpperCase() + sentence.slice(1);
}
return sentence
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment