ShareCopy to ClipboardRawPreviewconst maxN = (arr: Array<number>, n: number = 1) => [...arr].sort((a, b) => b - a).slice(0, n); Max elements array00gioyikCodiga's TypeScript RecipesReturns the n maximum elements from the provided array.0 CommentsAdd CommentLog in to add a comment