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

SQL Table Value Constructor – SELECT Statement (Create a Table With Value Generated By My Self)

SQL Table Value Constructor – SELECT Statement (Create a Table With Value Generated By My Self)

Java Stream intermediate operations are lazily executed

Java Stream intermediate operations are lazily executed

Command Line Interface (CLI) 超入門

Command Line Interface (CLI) 超入門


Comments