Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry for _.shuffle #342

Open
Uzlopak opened this issue Jul 1, 2022 · 6 comments
Open

Add entry for _.shuffle #342

Uzlopak opened this issue Jul 1, 2022 · 6 comments

Comments

@Uzlopak
Copy link
Contributor

Uzlopak commented Jul 1, 2022

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
}
@devendra66
Copy link

what we have to shuffle
in this

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Oct 3, 2023

?

What do you mean?

@devendra66
Copy link

what we have to shuffle in your website

@stevemao
Copy link
Member

What's the equivalent in lodash?

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Oct 17, 2023

@Uzlopak Uzlopak changed the title add shuffle Add entry for _.shuffle Oct 17, 2023
@stevemao
Copy link
Member

PR welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants