Skip to content

Instantly share code, notes, and snippets.

@AlexCheese
Forked from EliTheCoder/bint2bin.js
Last active November 30, 2018 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCheese/229e75b39389ff78c9503be9035d2051 to your computer and use it in GitHub Desktop.
Save AlexCheese/229e75b39389ff78c9503be9035d2051 to your computer and use it in GitHub Desktop.
function casefilter(input) {
let inparray = input.split(""); // creates array of chars
let lower = ""; // string of lowercase characters
let upper = ""; // string of uppercase characters
for (let i = 0; i < inparray.length; i++) {
let str = inparray[i].toString();
let fixedstr = str.toUpperCase();
if (str == " ") { // leave spaces separating words
upper += str;
lower += str;
} else if (str == fixedstr) { // if char uppercase
upper += str;
} else {
lower += str;
}
}
return lower + "\n" + upper; // outputs the result to the console
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment