Update InvertingCharactersCase.mjs

This commit is contained in:
Edosicca 2022-05-06 15:16:17 +02:00
parent e8913d152d
commit ddd6055800

View file

@ -33,8 +33,8 @@ class InvertingCharactersCase extends Operation {
* @returns {string} * @returns {string}
*/ */
run(input, args) { run(input, args) {
var result = ""; let result = "";
for(var i = 0; i < input.length; i++){ for (let i = 0; i < input.length; i++) {
result += this.checkAndChangeCase(input[i]); result += this.checkAndChangeCase(input[i]);
} }
return result; return result;
@ -44,9 +44,9 @@ class InvertingCharactersCase extends Operation {
* Check if a character is Uppercase or Lowercase * Check if a character is Uppercase or Lowercase
* and returns the opposite * and returns the opposite
*/ */
checkAndChangeCase(character){ checkAndChangeCase(character) {
try { try {
if(character.charCodeAt(0) > 64 && character.charCodeAt(0) < 91) if (character.charCodeAt(0) > 64 && character.charCodeAt(0) < 91)
return character.toLowerCase(); return character.toLowerCase();
else if (character.charCodeAt(0) > 96 && character.charCodeAt(0) < 123) else if (character.charCodeAt(0) > 96 && character.charCodeAt(0) < 123)
return character.toUpperCase(); return character.toUpperCase();