function toWeirdCase(string){
return string.split(' ').map(function(word){
console.log(word)
return word.split('').map(function(letter, index){
return index % 2 == 0 ? letter.toUpperCase() : letter.toLowerCase()
}).join('');
}).join(' ');
}
console.log(toWeirdCase("this is big"));
如:this is big 输出:ThIs Is BiG
一段语句 每个单词 基数位大写,偶数位小写
最新推荐文章于 2025-07-01 15:57:59 发布