If it value is greater than min value than iterate the loop upto first min value index and simply prvar it index value .
else { for ( i = 0 ; i < min ; i ++ ) document . write ( index ) ; document . write ( index ) ; } }