Created
February 1, 2017 06:59
-
-
Save DKunin/b359a2d775b2b2422fc2d9d16c33b834 to your computer and use it in GitHub Desktop.
Scramble text function
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
function randomInteger(min, max) { | |
var rand = min + Math.random() * (max - min) | |
rand = Math.round(rand); | |
return rand; | |
} | |
function scrabmle(text) { | |
const lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tincidunt justo at mattis eleifend. Vestibulum feugiat convallis porta. Maecenas convallis nunc bibendum velit luctus, in faucibus nibh venenatis. Nam lacinia pretium orci in elementum. Vivamus pretium risus elit, eleifend venenatis nulla pellentesque et. Proin at placerat arcu. Nunc ac posuere enim. Sed eu volutpat massa.`; | |
const len = text.length; | |
const randomStart = randomInteger(0, lorem.length - len); | |
return lorem.slice(randomStart, randomStart + len); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment