UNPKG

@twistezo/react-text-scramble

Version:
8 lines (7 loc) 325 B
export var randomItem = function (array) { return array[Math.floor(Math.random() * array.length)]; }; export var nextItem = function (array, currentItem) { var currentIndex = array.indexOf(currentItem); var bound = array.length; var nextIndex = (currentIndex + bound + 1) % bound; return array[nextIndex]; };