<script>
//思路使用Unicode数值进行切换
// 包装一个方法,将字符串大小写进行切换
let str = 'hGhasklgh'
function toggle(str) {
for (var index in str) {
var num = str[index]
if (num.charCodeAt(0) > 97 && num.charCodeAt(0) < 122) {
console.log(num.toUpperCase());
} else {
console.log(num.toLowerCase());
}
}
}
toggle(str)
</script>
前端,包装一个方法,将字符串大小写进行切换
猜你喜欢
转载自blog.csdn.net/weixin_40180205/article/details/104779317
今日推荐
周排行