<script>
var arr = new Array();
var key = 123456;
var iNum = 0;
var digits = key.toString().split('');
var realDigits = digits.map(Number)
console.log(realDigits);
$('.next-ball').on('click', function(){
var classList = ["white-ball", "blue-ball", "pink-ball", "green-ball", "yellow-ball"];
$('.lottery').append('<li class="lottery-ball ' + classList[Math.floor(0)] + '">' + realDigits[iNum] + '</li>');
console.log(arr);
//if lottery number calls is greater than 5 then switch button classes and send an alert to the user
if ( $('.lottery').children().length > 5 ) {
$('.next-ball').hide();
$('.play-again').show();
alert('Готовы к победе?');
}
iNum++;
});
//If once the game is finished the user chooses to play again switch button classes
$('.play-again').on('click', function(){
$('.lottery').children().remove();
iNum = 0;
arr = [];
$('.next-ball').show();
$('.play-again').hide();
});
</script>