I'm going to make a function that makes a random number that isn't equal to a specified number.
var number = 5;
var randnum2 = getrandnum(number);
function getrandnum(oldrandnum) {
var results = Math.round(Math.random() * 7);
if (results == oldrandnum) {
getrandnum(oldrandnum);
} else {
return results;
}
};
console.log(randnum2);
Explanation:
getrandnum
is my function and it generates a random number that doesn't equal 5
.
My problem is that the results will be NaN
some times.