From 2c27570e2b5768c0cec2283e852dd3fbcfbcab32 Mon Sep 17 00:00:00 2001 From: eneller Date: Wed, 23 Apr 2025 12:42:39 +0200 Subject: [PATCH] minor refactor --- src/app/app.component.html | 1 + src/app/app.component.ts | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index bbb5012..15b378d 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -36,6 +36,7 @@ + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1166eef..ab2e268 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -18,7 +18,7 @@ export class AppComponent implements OnInit { numTeamsSelected = 2; nTeamsValue = "4"; teamsArray: string[][] = []; - displayedColumns = ["teamCount", "teamNames"]; + duplicateNames: string[] = []; constructor(private activatedRoute: ActivatedRoute){} @@ -38,12 +38,14 @@ export class AppComponent implements OnInit { else{ this.numTeamsSelected = Number(this.numTeamsSelectorValue); } - let names = this.playerNamesValue + let nameslist = this.playerNamesValue .split('\n') .map(function(str){return str.trim();}) .filter(function(str){return str}); // boolean interpretation is same as non-empty // remove duplicates by using a Set - names = [...new Set(names)]; + let namesset = new Set(nameslist); + let names = [...namesset]; + var teams = Array.from({ length: this.numTeamsSelected }, () => []); var playersPerTeam = Math.floor(names.length / this.numTeamsSelected);
Removed: {{ duplicateNames }}
Size