📜  累积(“abcd”)->“A-Bb-Ccc-Dddd”累积(“RqaEzty”)->“R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy”累积(“cwAt”)->“C -Ww-Aaa-Tttt" - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:20.939000             🧑  作者: Mango

代码示例1
function accum(s) {
  var letters = s.split(''), words = [];

  for(var i = 0; i < letters.length; i++) {
    words.push(letters[i].toUpperCase() + Array(i + 1).join(letters[i].toLowerCase()));
  }

  return words.join('-');
}