Skip to content

Instantly share code, notes, and snippets.

@DZuz14 DZuz14/pitchers.js
Created Apr 27, 2019

Embed
What would you like to do?
ESPN MLB Pitcher Duplicates
1.) Grab each pitcher from table and their stats.
- Store them in object like:
```
{
'C. Sale': [5,2,3],
'H. Martinez': [20,9,4],
'R. Martinez': [3,7,1],
'J. Schmoe': [20,25,99],
'R. Kelly': [20,9,4],
'P. Kelly': [3,7,1],
}
```
2.) Grab meta data below the main table.
- Before extracting and storing the data, find out if there are any pitchers who have matching last names.
- Store them in an array like so:
`['Martinez', 'Kelly']`
- Start extracting the pitchers numbers for each statistic in the meta data(ie: First-pitch strikes/Batters Faced etc.).
- For each pitcher visited in the string check the following:
- If the current pitcher has a duplicate:
- Do a property look up in the object created in step 1 with the full string, 'H. Martinez' and add the stat to the array stored under his name.
- Else
- Loop through the pitchers names in the object that do not have duplicates, and append the proper first initial to their name:
- `['C. Sale', 'J. Schmoe']` <- Names taken from object in step 1.
- `'Sale-2-4-3-2;Schmoe-9-3-5-3'` <- Stats for Sale and Schmoe from `Called strikes-Swinging strikes-Foul balls-In play strikes` section.
- Extract the stats from the name in the string above, then add 'C.' to 'Sale', and 'J.' to 'Schmoe'
- Do a lookup on the object in step 1 using the newly formatted names, and add the numbers for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.