From d360d6c6371ceb1c558faf6848e29308bf95f044 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 30 Dec 2017 18:17:17 +0100 Subject: [PATCH] Add another quick fix to avoid accessing undefined values --- js/util.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 73273cf..f6e9c2e 100644 --- a/js/util.js +++ b/js/util.js @@ -102,7 +102,9 @@ function getDriverCodeAndPositionArray(raceData, lapNumber){ } 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){