i want to generate random number from -1 to 1 without getting any zero 0 like function should generate -1 or 1 no zero 0 i don’t need 0, i managed to do this but unfortunately im getting undefined on behalf of the zero can anyone explain me why this happed and how to solve this.
code —
function random(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
var save = Math.floor(Math.random() * (max - min + 1) + min)
if (save == 1 || save !== 0 && save !== undefined) {
return save
}
}
random(-1, 1)