Math.random()
Résolu/Fermé
Aminjer
Messages postés
47
Date d'inscription
dimanche 2 mars 2008
Statut
Membre
Dernière intervention
11 août 2011
-
2 mars 2008 à 12:05
Aminjer Messages postés 47 Date d'inscription dimanche 2 mars 2008 Statut Membre Dernière intervention 11 août 2011 - 20 mars 2008 à 21:14
Aminjer Messages postés 47 Date d'inscription dimanche 2 mars 2008 Statut Membre Dernière intervention 11 août 2011 - 20 mars 2008 à 21:14
1 réponse
Utilisateur anonyme
2 mars 2008 à 20:31
2 mars 2008 à 20:31
et ben :
var a;
a = Math.random();
ca va donner un chiffre entre 0 et 1, que tu peux arrondir a l'entier le plus proche avec Math.around(); et multiplier s'il faut un plus grand nombre.
exemple, pour avoir un nombre en tre 1 et 10;
var nmb;
do{
nmb = Math.random();
}while(((nmb=Math.around)*10)>10)
var a;
a = Math.random();
ca va donner un chiffre entre 0 et 1, que tu peux arrondir a l'entier le plus proche avec Math.around(); et multiplier s'il faut un plus grand nombre.
exemple, pour avoir un nombre en tre 1 et 10;
var nmb;
do{
nmb = Math.random();
}while(((nmb=Math.around)*10)>10)
20 mars 2008 à 21:14