Skip to content
loading...

JAVASCRIPT toggle upper to lower/lower to upper

github logo ・1 min read  

function isUpperCase(str) {
    return str === str.toUpperCase();
}

function isLowerCase(str) {
    return str === str.toLowerCase();
}


var upperLowerString  = "UpperLowerCasestring";
  upperLowerString = [...upperLowerString];  
var upperLowerStringToggled = upperLowerString.map(f => {
  if(isUpperCase(f))
    return f.toLowerCase();
  else
    return f.toUpperCase();

})
.reduce((a,b) => a+b);

console.log(upperLowerStringToggled);


twitter logo DISCUSS
Classic DEV Post from Jun 20 '19

What does a #codeNewbie need to start/improve?

ananthaprathyusha94 profile image
JAVASCRIPT