题解 | #数组方法---字符串变形#
字符串变形
http://www.nowcoder.com/practice/c3120c1c1bc44ad986259c0cf0f0b80e
function trans(s, n){
//write code here
const arr = s.split(' ').map((item)=>{
let word = item.split('');
for(let i=0;i<word.length;i++){
if(word[i].charCodeAt(0)<word[i].toLowerCase().charCodeAt(0)){
word[i] = word[i].toLowerCase(); //大写转为小写
}else{
word[i] = word[i].toUpperCase();
}
}
return word.join('');
})
return arr.reverse().join(' ');
}
module.exports = {
trans : trans
}