I got a problem, where I have to create a loop and make it go through an array, shuffling all the elements around and writing the new order with the same elements in a new array, so I can then output the new array further. Anyone know a solution?
//The array
var ARRAY = [
{
"name1"
},
{
"name2"
},
{
"name3"
},
{
"name4"
},
{
"name5"
}
];
i = 0;
while(i < receivedArray.length){
i++;
const correctAnswers = StartElements.splice(Math.floor(Math.random() * StartElements.length),1)[0];
answers.answer = correctAnswers.nameLV;
answers.correct = true;
answerArray.push(answers);
}
//what I've tried, but it doesn't select all the elements in the array, it outputs less than half of them