I want to write a function that checks if a random number is equal to a previous random number and returns a new random number not equal to the previous one. I want to use recursion to do this but I'm not sure if this is the correct syntax.
function newNumber(next,previous) {
if (next != previous)
return next;
else {
next = Math.floor(Math.random()*10);
newNumber(next, previous);
}
}
What would be the best way to get this to work?