📜  js 反向 str 案例 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:08.130000             🧑  作者: Mango

代码示例1
//Reverse the Case
function reverseCase(str) {
    return str.replace(/./g, c => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase());
}
console.log(reverseCase("Happy Birthday"));    // "hAPPY bIRTHDAY"
console.log(reverseCase("MANY THANKS"));    // "many thanks"
console.log(reverseCase("sPoNtAnEoUs"));    // "SpOnTaNeOuS"