JSFiddle - React, Tailwind, and code Playground
by zachpainter77
HTML
<span id="output">Hello</span>
JavaScript
function findNextPageIndex(arr, currentIndex) {
arr = arr.sort(function (a, b) { return a - b; });
return arr.reduceRight(function (prev, curr) { return prev > curr ? prev : ++curr; }, currentIndex);
}
function findNext(arr,currentIndex) {
arr = arr.sort(function (a, b) { return a - b; });
while(arr.indexOf(++currentIndex) > -1);
return currentIndex;
}
document.getElementById('output').innerText = findNext([2,4,5], 6);