Lista de amostras de JavaScript
const list = [1, 2, 3, 4, 5, 6];
// shuffle your list with the sort function:
const shuffledList = list.sort(() => Math.random() - 0.5);
// generate a size for the new list
const newListSize = Math.floor(Math.random() * list.length)
// pick the first "newListSize" elements from "shuffledList"
const newList = shuffledList.slice(0, newListSize)
console.log(newList);
// [3, 2, 6]; [5]; [4, 1, 2, 6, 3, 5]; []; etc..
Dark Dotterel