We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
实现思路: 1.把字符串用split分割为数组,遍历数组 2.对遍历的每个值进行toUpperCase()全等对比,如果相等证明这个字母原就是大写,进行小写转换,如果不相等说明取反成功,进行大写转换
代码实现
function changeStr(str) { const arr = str.split(''); const changeArr = arr.map(val => val = (val === val.toUpperCase()) ? val.toLowerCase() : val.toUpperCase()); return changeArr.join(''); } console.log(changeStr('abC123&ddD'))
注意:遇到特殊字符或者数字字符串,会返回原字符,不做处理
The text was updated successfully, but these errors were encountered:
No branches or pull requests
实现思路:
1.把字符串用split分割为数组,遍历数组
2.对遍历的每个值进行toUpperCase()全等对比,如果相等证明这个字母原就是大写,进行小写转换,如果不相等说明取反成功,进行大写转换
代码实现
注意:遇到特殊字符或者数字字符串,会返回原字符,不做处理
The text was updated successfully, but these errors were encountered: