Ruby Array Reduce Method Javascript Interviewbit