answer to Array#reduce