You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
fuiiiiiii, tiyunchen, TROLAAA, z0aiyx, linghucq1 and 20 morefuiiiiiii, z0aiyx, pma934, foreverstars, kokokele and 2 morefuiiiiiii, z0aiyx, shenjo, seho-dev, zouzhifeng and 1 morefuiiiiiii, z0aiyx, akeyz and MJscofieldfuiiiiiii, z0aiyx and RunoobTomfuiiiiiii, towavephone and z0aiyxfuiiiiiii and z0aiyxfuiiiiiii, towavephone, z0aiyx, aiyoubucuo, tigermmmmm and 1 more
constupperOrlower=(str)=>str.split('').reduce((acc,x)=>acc+=x==x.toLocaleUpperCase()? x.toLocaleLowerCase(): x.toLocaleUpperCase(),'')upperOrlower("what's THIS ?")// WHAT'S this ?
function test2(str) {
let arr = [];
for (let x of str) {
if (x === x.toUpperCase()) {
x = x.toLowerCase();
} else {
x = x.toUpperCase();
}
arr.push(x);
}
return arr.join("");
}
Activity
undefinedYu commentedon Apr 27, 2019
var reversal = function(str){
var newStr = '';
if(Object.prototype.toString.call(str).slice(8,-1) !== 'String'){
alert("请填写字符串")
}else{
for(var i=0;i<str.length;i++){
newStr += ((str.charCodeAt(i)>96 && str.substr(i,1).toUpperCase()) || str.substr(i,1).toLowerCase());
}
}
return newStr;
}
linghucq1 commentedon May 8, 2019
lantian1024 commentedon May 15, 2019
fuiiiiiii commentedon May 22, 2019
likeke1997 commentedon Jun 5, 2019
MartinsYong commentedon Jun 21, 2019
Konata9 commentedon Jul 2, 2019
Azathoth-H commentedon Jul 12, 2019
seho-dev commentedon Jul 14, 2019
学习到了,借鉴到了;
function test(str) {
return str.replace(/([a-z])([A-Z])/g, (m, s1, s2) => {
return
${s1.toUpperCase()}${s2.toLowerCase()}
;});
}
function test2(str) {
let arr = [];
for (let x of str) {
if (x === x.toUpperCase()) {
x = x.toLowerCase();
} else {
x = x.toUpperCase();
}
arr.push(x);
}
return arr.join("");
}
console.log(test("a6M3cH"));
shufangyi commentedon Jul 18, 2019
wyx2014 commentedon Jul 24, 2019
gu-xionghong commentedon Jul 25, 2019
IanSun commentedon Jul 26, 2019
wsb260 commentedon Jul 31, 2019
69 remaining items