Last active
April 28, 2020 00:35
-
-
Save TenzenIga/2e69b420796c8d4ed40ed02f864c172d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export const getScore = (offset: number) : {home: number, away: number} => { | |
let start = 0; | |
let end = scoreStamps.length - 1 | |
let guess = Math.floor((start + end) / 2); | |
while(start <= end){ | |
if(offset === scoreStamps[guess].offset){ | |
return scoreStamps[guess].score | |
} | |
if(offset > scoreStamps[guess].offset ){ | |
start = guess + 1; | |
}else if( offset < scoreStamps[guess].offset){ | |
end = guess -1; | |
} | |
guess = Math.floor((start + end) / 2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment