I've got an array, rWords that could be any length. I'm trying to develop a function that chooses six at random and assigns them as text in six divs, that will be options for users to click in a quiz type game.
My problem: I can get a random array of six words from rWords and assign them as text. However it sometimes happens that you get the same word twice in the array, which i dont want.
The random word funtion: (there are six squares on the html)
Function randomWord(){
  var pArr = [];
  for (i=0; i<squares.length; i++){
    var p = Math.floor(Math.random() * rWords.length);
    pArr.push(rWords[p]);
  }
  return pArr;
}
I'm trying to return as an Array so I can use Array.from(set) to create a unique array for the 'answers' I havnt completed the squares function fully as everything I've tried doesnt work. When I was returning random words one at a time it was
I cannot get the array to pass as a single Array. I can get six arrays to pass, with one element in each.
To fill the squares:
For(i=0; i<squares.length;i++){
  Squares[i].textcontent = randomWord();
}
 
     
    