Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
982 B
1
Indexable
Never
function convertCase(lowercaseString, uppercaseString) {
  var convertedLower = "";
  var convertedUpper = "";

  for (var i = 0; i < lowercaseString.length; i++) {
    var char = lowercaseString[i];
    var charCode = char.charCodeAt(0);

    if (charCode >= 97 && charCode <= 122) {
      // Convert lowercase to uppercase
      char = String.fromCharCode(charCode - 32);
    }
    convertedLower += char;
  }

  for (var j = 0; j < uppercaseString.length; j++) {
    var char = uppercaseString[j];
    var charCode = char.charCodeAt(0);

    if (charCode >= 65 && charCode <= 90) {
      // Convert uppercase to lowercase
      char = String.fromCharCode(charCode + 32);
    }
    convertedUpper += char;
  }

  return [convertedLower, convertedUpper];
}

var lower = "hello";
var upper = "WORLD";
var result = convertCase(lower, upper);

console.log("Converted Lowercase: " + result[0]);  // Output: "HELLO"
console.log("Converted Uppercase: " + result[1]);  // Output: "world"