码迷,mamicode.com
首页 > 其他好文 > 详细

大小写转换

时间:2019-07-31 15:20:53      阅读:90      评论:0      收藏:0      [点我收藏+]

标签:fun   turn   height   ase   split   大小写   item   解析   code   

题目:将大写转换为小写,将小写转换为大写;如:“AbC”??“aBc”。

 

解析:

function processString (s) {
    var arr = s.split(‘‘);
    var new_arr = arr.map((item) => {
        return item === item.toUpperCase() ? item.toLowerCase() : item.toUpperCase();
    });
    return new_arr.join(‘‘);
}
console.log(processString(‘AbC‘));

技术图片

 

大小写转换

标签:fun   turn   height   ase   split   大小写   item   解析   code   

原文地址:https://www.cnblogs.com/anbozhu7/p/11276018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!