From bf9f3ce20e43cf442f511f0f5d7bfe27b50b54bb Mon Sep 17 00:00:00 2001 From: tresabhi Date: Sat, 3 Jun 2023 00:38:57 +0000 Subject: [PATCH] fix: edge case; new tanks don't have averages --- src/commands/stats.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands/stats.tsx b/src/commands/stats.tsx index ee6e30b45..1ed746868 100644 --- a/src/commands/stats.tsx +++ b/src/commands/stats.tsx @@ -88,9 +88,12 @@ export default { WN8: entries.reduce((accumulator, [tankIdString, stats]) => { const tankId = Number(tankIdString); - const tankWN8 = getWN8(tankAverages[tankId].all, stats); - return accumulator + tankWN8 * stats.battles; + // edge case where new tanks don't have averages + if (tankAverages[tankId]) { + const tankWN8 = getWN8(tankAverages[tankId].all, stats); + return accumulator + tankWN8 * stats.battles; + } else return accumulator; }, 0) / totalBattles, };