JSFiddle - React, Tailwind, and code Playground
HTML
<button>Test!</button>
JavaScript
function testall(){
var sizes = [10,100,1000,2000,3000,4000,5000,10000, 50000];
for (var i = 0; i < sizes.length; i++) {
var n = sizes[i];
if(!testhash(n)){
alert("test failed at hash of length: " + n);
return
}
}
alert("all tests passed");
}
function testhash(n){
var somestring = "#" + makestring(n);
window.location.hash = somestring;
var success = (window.location.hash == somestring);
return success
}
function makestring(n){
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < n; i++ ){
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
$("button").on("click", testall);