-
-
Save aleksey-rezvov/82c6ac7f1cc18bc97ffc59021b030a43 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 emptyScoreStamp = { | |
offset: 0, | |
score: { | |
home: 0, | |
away: 0 | |
} | |
}; | |
export const scoreStamps = Array(50000).fill(emptyScoreStamp).map( | |
((acc) => () => { | |
const scoreChanged = Math.random() > 0.9999; | |
const homeScoreChange = scoreChanged && Math.random() > 0.55 ? 1 : 0; | |
const awayScoreChange = scoreChanged && !homeScoreChange ? 1 : 0; | |
return { | |
offset: acc.offset += Math.floor(Math.random() * 3) + 1, | |
score: { | |
home: acc.score.home += homeScoreChange, | |
away: acc.score.away += awayScoreChange | |
} | |
}; | |
} | |
)(emptyScoreStamp) | |
); | |
export const getScore = (offset: number) : {home: number, away: number} => { | |
// continue the function's implementation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment