Randomly adds class to an element in a container

If the element already has got the class than the function tries again randomly to select another element.

The function also displays the counts of the attempted times and shows the repeated selected element.

Attempt:

Repeated attempt on the element