The thing is i want to add random number to a variable which is initially 0 which has to happen after a random timoeut until the variable reaches 100.
$scope.var1 = 0;
do{
$timeout(function(){
$scope.var1 += Math.floor(Math.random * 100 +1);
},Math.floor(Math.random * 100 +1));
console.log($scope.var1);
}while($scope.var1<100)
$scope.var1 always stays 0, hence it goes to an infinite loop;
Aucun commentaire:
Enregistrer un commentaire