DAY13:Mumbling


Posted by birdbirdmurmur on 2023-07-26

題目連結

Mumbling

解法

function accum(s) {
  s = s.toLowerCase();
    let result = '';
    for (let i = 0; i < s.length; i++) {
      result += s[i].toUpperCase() + s[i].repeat(i) + '-';
    }
  return result.slice(0, -1);
}

筆記

避免亂數先全部變成小寫
照著第一個字大寫 後面小寫的規則
使用迴圈來暴力破解
最後刪掉最後一個字


#javascript #Codewars







Related Posts

簡明程式解題入門 - 字串篇 I

簡明程式解題入門 - 字串篇 I

實作 Redux(五):reducer

實作 Redux(五):reducer

自駕車 Software Stack 架構介紹

自駕車 Software Stack 架構介紹


Comments