minor refactor
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<table class="table table-striped custom-table">
|
<table class="table table-striped custom-table">
|
||||||
|
<caption *ngIf="duplicateNames.length >0">Removed: {{ duplicateNames }}</caption>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Size</th>
|
<th scope="col">Size</th>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export class AppComponent implements OnInit {
|
|||||||
numTeamsSelected = 2;
|
numTeamsSelected = 2;
|
||||||
nTeamsValue = "4";
|
nTeamsValue = "4";
|
||||||
teamsArray: string[][] = [];
|
teamsArray: string[][] = [];
|
||||||
displayedColumns = ["teamCount", "teamNames"];
|
duplicateNames: string[] = [];
|
||||||
|
|
||||||
constructor(private activatedRoute: ActivatedRoute){}
|
constructor(private activatedRoute: ActivatedRoute){}
|
||||||
|
|
||||||
@@ -38,12 +38,14 @@ export class AppComponent implements OnInit {
|
|||||||
else{
|
else{
|
||||||
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
|
this.numTeamsSelected = Number(this.numTeamsSelectorValue);
|
||||||
}
|
}
|
||||||
let names = this.playerNamesValue
|
let nameslist = this.playerNamesValue
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(function(str){return str.trim();})
|
.map(function(str){return str.trim();})
|
||||||
.filter(function(str){return str}); // boolean interpretation is same as non-empty
|
.filter(function(str){return str}); // boolean interpretation is same as non-empty
|
||||||
// remove duplicates by using a Set
|
// 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 teams = Array.from({ length: this.numTeamsSelected }, () => []);
|
||||||
var playersPerTeam = Math.floor(names.length / this.numTeamsSelected);
|
var playersPerTeam = Math.floor(names.length / this.numTeamsSelected);
|
||||||
|
|||||||
Reference in New Issue
Block a user