Looking at this function:
const mode = arr =>
arr.reduce(
(a,b,i,arr) => (arr.filter(c=> c === a).length >= arr.filter(c => c === b).length) ? a : b,
null
)
console.log(mode([500, 450, 400, 400, 375, 350, 325, 300])) // 400
It appears that the reduce function is being used with a custom function as the first argument and null as the second. The custom function inside looks like it's creating a ternary conditional comparing elements of the array.
I'm still unsure about the inner workings of this code and would appreciate a simple breakdown to understand it better. Currently, it seems to work for finding the mode if there is only one in the array, which is fine for now, but I may need to address that later.
Here is a link to a CodePen where you can test it out.