Random int array in range

    0

    1

    Giovanny Gongora

    Codiga's TypeScript Recipes

    Generates an array of n random integers in the specified range.

    const randomIntArrayInRange = (min: number, max: number, n: number = 1) =>
      Array.from(
        { length: n },
        () => Math.floor(Math.random() * (max - min + 1)) + min
      );
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.