题解 | #字符串变形#

字符串变形

http://www.nowcoder.com/practice/c3120c1c1bc44ad986259c0cf0f0b80e

		function trans(s, n) {
            let arr = s.split(/\s/);
            let res = [];
            let temp;
            while (arr.length) {
                temp = arr.pop()
                temp = temp.split('')
                temp.forEach((word,i) => {
                    if (/[a-z]/.test(word)) {
                        temp[i] = word.toUpperCase()
                    }else if (/[A-Z]/.test(word)) {
                        temp[i] = word.toLowerCase()
                    }
                });
                res.push(temp);
                res.push(' ')
            }
            res.pop()
            res = res.toString().replace(/,/g,'')
            return res
        }
 
module.exports = {
    trans : trans
}
全部评论

相关推荐

06-20 14:27
中山大学 C++
rt,day3就开始接需求
星际探神:你就想 你是水货他们都没面出来 他们也水 管他呢
点赞 评论 收藏
分享
点赞 评论 收藏
分享
05-26 22:25
门头沟学院 Java
Java小肖:不会是想叫你过去把你打一顿吧,哈哈哈
点赞 评论 收藏
分享
nus22016021404:兄弟,你这个简历撕了丢了吧,就是一坨,去找几个项目,理解项目流程,看几遍就是你的了,看看八股就去干了,多看看牛客里别人发出来的简历,对着写,你这写的啥啊,纯一坨
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务