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