https://blog.leoho.dev/posts/javascript-array-reduce-tips/