i need help with aray
hello how can i all item in aray Random with no reapeat ? in java script ! what is the simplest way to this
8 Replies
:FRjs:
You're asking how to get all unique items in an array? There's a lot of different ways, but the easiest one imo is to make your array a Set
https://stackoverflow.com/a/42123984/13264587
i want get all item but random
sort by math.random:
arr.sort(() => Math.random() - 0.5)
👀 why the
- 0.5
?sort expects a positive or negative value, Math.random() returns a value between 0 and 1
Ohhh I see
tnx very much it was eazyest way