Use Array.reduce.