How can I generate random numbers without repetition?

Asked

Viewed 28 times

1

I have this code to generate a random number between 0 and 10, but sometimes it doesn’t find the number between 10.

for(var i=0; i<10; i++) {
    var buscar = Math.round(Math.random() * 10);
    if(buscar == caixaDoNumero.value) {
        alert("O segredo e: " + segredo); 
        break;
    }
}

Without increasing the size of the for.

  • This may also be http://answall.com/q/94646/101

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.