0

I have a problem in my slot machine, How to make it always display 3 digit For example, I random the number 001 - 200

I want it to show 001 from start and I want to display number like this 002 010 067 when it stop random

$('.reel-container:first').slotMachine(001).toString();

$('#gen').click(function() {
    $('.reel-container:first').slotMachine((Math.floor(Math.random() * 200) + 1).toString());
});

My jsfiddle https://jsfiddle.net/xmenzaa/mrs93b58/11/

Thanks

1 Answers1

0

use this function to generate random number

function randGen(){
    var  randNum = (Math.floor(Math.random() * 200) + 1).toString()
    if(a.toString().length==3){
        return  randNum;
    }
    else if(a.toString().length==2){
        return "0"+ randNum;
    }
    else if(a.toString().length==1){
        return "00"+ randNum;
    }
}

this code generate 3 digit random number and use it in

$('.reel-container:first').slotMachine(randGen());
mahradbt
  • 364
  • 1
  • 2
  • 12