题解 | #字符串变形#

字符串变形

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

  function trans(str){
  str=str.split(' ')
let res=[]
  while(str.length){
    let temp=str.pop()
   let temp1=temp.split('')
   temp1.forEach((item,index,arr)=>{
    if(/[a-z]/.test(item)){
      arr[index]=item.toUpperCase()
    }else if(/[A-Z]/.test(item)){
      arr[index]=item.toLowerCase()
    }
   })
   temp1=temp1.join('')
  res.push(temp1)
  }
  console.log(res);
  return res.join(' ')
}

module.exports = { trans : trans }

全部评论

相关推荐

生命诚可贵:先不说内容怎么样 排版就已经太差劲了 第一眼看不到重点,第二眼已经没有再看的耐心了, 篇幅占的太满了 字体不要用灰色 观感不好 想重点突出的黑色加粗就可以了 多列要点 少些大段的句子 项目经历把项目用的技术要点列出来,光写个python plc什么的太宽泛了 自我评价也有点偏多
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务