Simple way to avoid previous number in Math.random?
<p>I am working on a random quote/color generator. I want it to avoid repeating previous color (in a simple/easy/understandable way as I'm a complete beginner in JS/jQuery).</p>

<p>Here is my code, I don't know what is wrong with it.</p>

<pre><code>  var colors = ["#8ee5ee", "#ee82ee", "#469649", "#ff4444", "#ffa500", "#dddddd", "#efc3c8", "#d2d449", "#f91589","#906161","#875d39","#ffdab9","#d1e529","#3a718b"];

  var color = Math.floor(Math.random() * colors.length);

  var lastcolor = 0;

  while(color === lastcolor){
    color = Math.floor(Math.random() * colors.length) + 1;
  }

  $("body").animate({backgroundColor: colors[color]}, 1000);
  $("#new-quote").animate({backgroundColor: colors[color]}, 1000);
  $("h6").fadeOut(1000);
  $("p").fadeOut(1000);

   });
  });
</code></pre>

<p>Basically, when I click a button (<code>#new-quote</code>), the current background color changes to another random color and so on. But now and then the color doesn't change as the machine chose the same number/color as the current one. I'm trying to avoid that!</p>