[O] Also support numeric grade

This commit is contained in:
Hykilpikonna
2019-11-06 21:30:15 -05:00
parent b0d3bf4bd2
commit 2504b37eb7
+9 -2
View File
@@ -112,9 +112,16 @@ export class GPAUtils
*
* @param grade Letter grade or numeric grade
*/
public static findScale(grade: string): Scale | undefined
public static findScale(grade: string | number): Scale | undefined
{
return this.SCALE.find(scale => scale.letter == grade);
// Letter grade
if (typeof grade == 'string')
{
return this.SCALE.find(scale => scale.letter == grade);
}
// Numeric grade
return this.SCALE.find(scale => grade >= scale.min);
}
/**