1684838553 / arithmeticQuestions

程序员的算法趣题
2 stars 0 forks source link

字符串大小写字母转换 #20

Open 1684838553 opened 1 year ago

1684838553 commented 1 year ago
let str = 'aBcDeFgH'
let arr = []
for(let item of str) {
  if (item === item.toUpperCase()) {
    item = item.toLowerCase()
  } else {
    item = item.toUpperCase()
  }
  arr.push(item)
}
let newStr = arr.join('')
console.log(newStr)
// AbCdEfGh