Javascript Array Reduce Is Not A Function