JSFiddle - React, Tailwind, and code Playground
by Thomas Upton
JavaScript
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function generateRandomWithExclusion(exclude, min, max) {
var num = getRandomInt(min, max);
while (num === exclude) {
num = geRandomInt(min, max);
}
return num;
}
console.log(generateRandomWithExclusion(2, 0, 10));