您的位置:首页 > 其它

一段语句 每个单词 基数位大写,偶数位小写

2017-01-13 15:25 246 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐