mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-09 07:45:00 -04:00
Update InvertingCharactersCase.mjs
This commit is contained in:
parent
e8913d152d
commit
ddd6055800
1 changed files with 4 additions and 4 deletions
|
@ -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();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue