From a8cdc6f449b245d61c2e65f684262f34c1ea8137 Mon Sep 17 00:00:00 2001 From: vexorian Date: Tue, 21 Nov 2023 14:37:45 -0400 Subject: [PATCH] Fix median condition not working when the number of filler videos in a channel is odd. --- src/helperFuncs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helperFuncs.js b/src/helperFuncs.js index 9ed0755..da291ce 100644 --- a/src/helperFuncs.js +++ b/src/helperFuncs.js @@ -345,8 +345,9 @@ function getMedian(channelCache, channel, fillers) { if (times.length == 0) { return null; } - quickselect(times, times.length / 2) - return times[times.length / 2]; + let m = Math.floor(times.length / 2); + quickselect(times, m) + return times[m]; }