const maxN = (arr: Array<number>, n: number = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
      
      Typescript language logo

      Max elements array

      Codiga's TypeScript Recipes

      Returns the n maximum elements from the provided array.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.