I have a mapping function that iterates over an array of items. I already sliced the data to select only a small handful of data to display. However now I also want the mapping to select random items from the array.
const randomStocks = Math.floor(Math.random() * buckets.stock_count);
Here is my mapping function:
{bucket.stock_list.slice(0, 4).map((stock, index) =>
{return(
<Chip key={index} label={stock} />
)}
)}
Where and how can I add my randomStocks
in my mapping function while respecting the slicing of data?