/    Sign up×
Community /Pin to ProfileBookmark

I need help about Array in javascript

I need help about mix and sort arrays in javascript, I have a array get from checkbox here https://drive.google.com/file/d/1ziTUFULJ02kEdPu3LOHdl0GQ-PaunC2z/view

Now I need handle that array, example I check 10 values [01 02 04 05 16 18 22 26 39 55 ]
I just want to output 6 values ​​the array will take all the rest, mix and sort ascending
ex :

  • 1. 01 02 04 05 16 18

  • 2. 01 16 18 22 26 39

  • 3. 04 05 22 26 39 55
    ……
  • How do write this array loop code ?

    to post a comment
    JavaScript

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @boohooOct 13.2021 — You can get all combinations of the length of n with this function:

    ``javascript<i>
    </i>function combinations(items, n) {
    const result = [];

    if (n === 1) return items.map(item =&gt; [item]);

    for (let i = 0; i &lt; items.length - n + 1; i++) {
    result.push(
    ...combinations(items.slice(i + 1), n - 1).map(
    t =&gt; [...items.slice(i, i + 1), ...t]
    )
    );
    }

    return result;
    }<i>
    </i>
    `</CODE>
    Then, you can get all possible combination simply with:
    <CODE lang="javascript">
    `javascript<i>
    </i>const groups = combinations(checkboxes, 6);<i>
    </i>
    ``
    Copy linkTweet thisAlerts:
    @laonhjauthorOct 13.2021 — @boohoo#1638156

    Ok , Thank You Verry Much , I understood the problem.
    ×

    Success!

    Help @laonhj spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.25,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...