Reduce Function Array Javascript Length Of Integer Python