You-Dont-Need-Lodash-Underscore icon indicating copy to clipboard operation
You-Dont-Need-Lodash-Underscore copied to clipboard

Add entry for _.shuffle

Open Uzlopak opened this issue 2 years ago • 6 comments

shuffle can be implemented like this:

function shuffle (array) {
  const result = array.slice()
  const len = result.length
  let tmp
  let rndPos = 0
  for (let i = 0; i < len; ++i) {
    tmp = result[rndPos = i + Math.floor(Math.random() * (len - i))]
    result[rndPos] = result[i]
    result[i] = tmp
  }
  return result
}

Uzlopak avatar Jul 01 '22 19:07 Uzlopak

what we have to shuffle in this

devendra66 avatar Oct 03 '23 08:10 devendra66

?

What do you mean?

Uzlopak avatar Oct 03 '23 09:10 Uzlopak

what we have to shuffle in your website

devendra66 avatar Oct 03 '23 10:10 devendra66

What's the equivalent in lodash?

stevemao avatar Oct 13 '23 05:10 stevemao

@stevemao

Its shuffle: https://lodash.com/docs/4.17.15#shuffle

Uzlopak avatar Oct 17 '23 07:10 Uzlopak

PR welcome

stevemao avatar Oct 18 '23 23:10 stevemao