JSFiddle - React, Tailwind, and code Playground
by Jake Overall
JavaScript
//CoderByte Challenge SwapCase
function splitStr(str) {
var result = [];
str.split("");
for (var i = 0; i < str.length; i++) {
if (str[i] === str[i].toUpperCase()) {
result.push(str[i].toLowerCase());
} else if (str[i] === str[i].toLowerCase()) {
result.push(str[i].toUpperCase());
} else {
result.push(str[i]);
}
}
console.log(result.join(""));
}
splitStr("This is a test");