Created
March 8, 2019 20:31
-
-
Save joziahg/bfbc3b0d4a94b146918dad42067b697c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const softballTeams = [ // Array of teams | |
'Ottumwa', 'Benton', 'Bettendorf', 'IC Regina', 'CR Kennedy', | |
'Cedar Falls', 'Dub. Senior', 'Dub. Hempstead', 'North Scott', | |
'CR Prairie', 'IC West', 'Pleasant Valley', 'Linn-Mar', 'CCA', | |
'Lisbon', 'CR Jeff Blue', 'CR Jeff White', 'CR Xavier', 'Waterloo West' | |
] | |
Array.prototype.getPairs = function (returnedPairs) { // We can define ourselves a new Array function here with the Array.protptype method | |
var pairs = [] // new pairs array | |
for (var teamOneIndexPosition = 0; teamOneIndexPosition < this.length - 1; teamOneIndexPosition++) { | |
for (var teamTwoIndexPosition = teamOneIndexPosition; teamTwoIndexPosition < this.length - 1; teamTwoIndexPosition++) { | |
returnedPairs([this[teamOneIndexPosition], this[teamTwoIndexPosition+1]]) | |
} | |
} | |
} | |
var allPossibleTeamCombos = [] | |
softballTeams.getPairs(function(returnedPairs){ // add all the possible teams to memory | |
allPossibleTeamCombos.push(returnedPairs) | |
}) | |
const allPossibleTeamCombosToString = allPossibleTeamCombos.map(teamCombo => teamCombo.toString()) | |
const sortTeamsOne = allPossibleTeamCombosToString.filter(teamCombo => { | |
switch(teamCombo){ | |
case 'Ottumwa,CR Jeff Blue': | |
case 'Bettendorf,North Scott': | |
case 'Bettendorf,Pleasant Valley': | |
case 'Dub. Senior,Dub. Hempstead': | |
case 'North Scott,Pleasant Valley': | |
case 'Lisbon,CR Jeff Blue': | |
return false | |
default: | |
return true | |
} | |
}) | |
console.log(sortTeamsOne) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment