Add another quick fix to avoid accessing undefined values

This commit is contained in:
Jan Philipp Timme 2017-12-30 18:17:17 +01:00
parent 18566d9bc2
commit d360d6c637
1 changed files with 3 additions and 1 deletions

View File

@ -102,7 +102,9 @@ function getDriverCodeAndPositionArray(raceData, lapNumber){
} }
function getDriverCodeById(raceData, driverId){ function getDriverCodeById(raceData, driverId){
return raceData.drivers.filter(driv => driv.driverId == driverId)[0].code; var driverData = raceData.drivers.filter(driv => driv.driverId == driverId)[0];
if(driverData === undefined) return "XXX"; // TODO: Do a real fix instead of this quick fix
return driverData.code;
} }
function removeDuplicates(result,obj){ function removeDuplicates(result,obj){