Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js reverse str case

//Reverse the Case
function reverseCase(str) {
	return str.replace(/./g, c => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase());
}
console.log(reverseCase("Happy Birthday"));	// "hAPPY bIRTHDAY"
console.log(reverseCase("MANY THANKS"));	// "many thanks"
console.log(reverseCase("sPoNtAnEoUs"));	// "SpOnTaNeOuS"
 
PREVIOUS NEXT
Tagged: #js #reverse #str #case
ADD COMMENT
Topic
Name
3+7 =