假如我有这样2个函数:function capitalize (string) { return string.charAt(0).toUpperCase() + string.slice(1)}function hyphenate (strings) { let hyphenated = '' strings.forEach((str, idx, strs) => { if (idx === strs.length - 1) { hyphenated += capitalize(str) } else { hyphenated += capitalize(str) + '-' } }) return hyphenated}我现在想让hyphenate不再依赖capitalize, 有什么好的方法吗?
添加回答
举报
0/150
提交
取消