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
NIMA
NIMAOP•7mo ago
:FRjs:
vince
vince•7mo ago
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
NIMA
NIMAOP•7mo ago
i want get all item but random
Jochem
Jochem•7mo ago
sort by math.random: arr.sort(() => Math.random() - 0.5)
vince
vince•7mo ago
👀 why the - 0.5?
Jochem
Jochem•7mo ago
sort expects a positive or negative value, Math.random() returns a value between 0 and 1
vince
vince•7mo ago
Ohhh I see
NIMA
NIMAOP•7mo ago
tnx very much it was eazyest way
Want results from more Discord servers?
Add your server