Home >Web Front-end >JS Tutorial >Reverse the case of a string - Javascript
Write a function that takes a string and reverses the case of all its letters.
function reverseStringCase(text) { let reversedString = []; for (let i = 0; i item === item.toUpperCase() ? item.toLowerCase() : item.toUpperCase() ) .join(""); console.log(reversedString); return reversedString; } reverseStringCase( "L'âme nE se dÉvelopPe pAs sAnS ChAngEmenT, eT leS DoUtes Sont EsSentIels à la crOisSanCe." ); reverseStringCases( "L'âme nE se dÉvelopPe pAs sAnS ChAngEmenT, eT leS DoUtes Sont EsSentIels à la crOisSanCe." );
l'ÂME Ne SE DéVELOPpE PaS SaNs cHaNGeMENt, Et LEs dOuTES sONT eSsENTiELS À LA CRoISsANcE. l'ÂME Ne SE DéVELOPpE PaS SaNs cHaNGeMENt, Et LEs dOuTES sONT eSsENTiELS À LA CRoISsANcE.
The above is the detailed content of Reverse the case of a string - Javascript. For more information, please follow other related articles on the PHP Chinese website!