title: toggle a random class with jquery
body: <p>the idea is having a button that, when clicked, adds a random class picking it from an array to another div. what i want is having that same button to remove any randomly added class from it when i re-click it.</p>
  
  <p>here's a fiddle: <a href="https://jsfiddle.net/jLmj7bwk/1/" rel="nofollow">https://jsfiddle.net/jLmj7bwk/1/</a></p>
  
  <p>and this is the function</p>
  
  <pre><code>$(".button").click(function() {
  
      var classes = ['one', 'two', 'three'];
      var randomnumber = Math.floor(Math.random() * classes.length); 
  
      $(".element").toggleClass(classes[randomnumber]);   
  
      if  ($(this).text() == "cancel added class")
          $(this).text("add random class")
  
  
      else
          $(this).text("cancel added class");
  
  });
  </code></pre>
  
  <p>this does add a class, but it keeps on adding them without removing it.
  could you help? thanks a lot!</p>