对于给定字符串中的每个字母,为字母创建字谜。使用map()将字母与每部分字谜组合,然后使用reduce()将所有字谜组合到一个数组中,最基本情况是字符串长度等于2或1。...首字母大写
使用slice(0,1)和toUpperCase()大写第一个字母,slice(1)获取字符串的其余部分。...const flatten = arr => arr.reduce((a, v) => a.concat(v), []);
// flatten([1,[2],3,4]) -> [1,2,3,4]
从数组中获取最大值...const arrayMax = arr => Math.max(...arr);
// arrayMax([10, 1, 5]) -> 10
从数组中获取最小值
使用Math.min()与spread...(按字母顺序排列)
使用split('')分割字符串,sort()使用localeCompare(),使用join('')重新组合。