title: Pick 3 random elements from an array. And not get the same elements twice
body: <p>I am trying to get this function to print out three random names without using the same name twice. I started trying with an If inside the for-loop, but have no idea if that is correct. Appriciate all help as i feel kinda stuck at this point in learning Javascript. </p>
  
  <pre><code>var name = ["Kai", "Lars", "Anders", "Ole", "Petter", "Mikael", "Cos", "Sin"];  
  var randName = [];
  
      function randomNavn(){
          document.getElementById("utskrift").innerHTML = "";
          for( i = 0; i &lt; 3; i++){
              randName.push(name.splice(Math.floor(Math.random() * name.length), 1));
  
              if(name[i] === randName[i]){
  
              }
          }
          document.getElementById("utskrift").innerHTML = randName.join(" , ");
      }
  </code></pre>