JSFiddle - React, Tailwind, and code Playground
JavaScript
Array.prototype.shuffle = function() {
return this.sort(function() {
return 0.5 - Math.random();
});
};
var nums = "123456789".split("");
const custom = "000".split("");
function getRandomNumber () {
nums.shuffle();
for (i in custom) {
nums[i] = custom[i];
}
while(nums[0] == 0){
nums.shuffle();
}
return +nums.join("");
}
document.body.appendChild(document.createTextNode(getRandomNumber()));