Skip to content

Conversation

@Danmax
Copy link
Contributor

@Danmax Danmax commented Oct 2, 2025

PR Description:

This script generates random pairs from an input array. It is designed to take an array of items (e.g., cars, players, names) and shuffle them before grouping them into pairs. If the number of elements is odd, the last element will remain unpaired in a single-element array.

Pull Request Checklist

Overview

  • I have read and understood the CONTRIBUTING.md guidelines
  • My pull request has a descriptive title that accurately reflects the changes
  • I've included only files relevant to the changes described in the PR title and description
  • I've created a new branch in my forked repository for this contribution

Code Quality

  • My code is relevant to ServiceNow developers
  • My code snippets expand meaningfully on official ServiceNow documentation (if applicable)
  • I've disclosed use of ES2021 features (if applicable)
  • I've tested my code snippets in a ServiceNow environment (where possible)

Repository Structure Compliance

  • I've placed my code snippet(s) in one of the required top-level categories:
    • Core ServiceNow APIs/
    • Server-Side Components/
    • Client-Side Components/
    • Modern Development/
    • Integration/
    • Specialized Areas/
  • I've used appropriate sub-categories within the top-level categories
  • Each code snippet has its own folder with a descriptive name

Documentation

  • I've included a README.md file for each code snippet
  • The README.md includes:
    • Description of the code snippet functionality
    • Usage instructions or examples
    • Any prerequisites or dependencies
    • (Optional) Screenshots or diagrams if helpful

Restrictions

  • My PR does not include XML exports of ServiceNow records
  • My PR does not contain sensitive information (passwords, API keys, tokens)
  • My PR does not include changes that fall outside the described scope

Danmax added 3 commits October 2, 2025 17:08
Readme file for the Arry matched function
Updated code script
updated read me
@WillemZeiler WillemZeiler self-assigned this Oct 2, 2025
@Danmax
Copy link
Contributor Author

Danmax commented Oct 2, 2025

Here is my first pull request, thank you.

Copy link
Contributor

@WillemZeiler WillemZeiler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. I have added 2 comments to your file that need updating. One is in the description, as the intended usage of this scripts output is not clear from the description. The other is in the code.

}


var randomPairs = createRandomPairs(inputs.wheels);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you expect an input with a "wheels" element, but this is not specified anywhere. Can you in the readme add the expected input format/instructions, or update this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yes I need to refactor this pull request.
I need to better explain this function snippet and its use cases.

---

## How It Works
1. **Shuffle the Input Array**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be enough to have random pairs? If you shuffle the array then f.e. 0 and 1 can be a random pain. What does the pushing the 2 pairs together in a paired array help do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a Function to take a list of players, in this case was from a Racing Competition Tournament app, where each car is represented by wheels and it would randomize the list of input sys ids and randomize a new order array. Then, from that new list order, it can generate pairs of head-to-head matches according to tournament rules preferences.

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

Successfully merging this pull request may close these issues.

2 participants