Skip to content

Instantly share code, notes, and snippets.

@jbass86
Created January 17, 2022 22:08
Show Gist options
  • Save jbass86/babf16bf7f474e7920a8baf2056237e2 to your computer and use it in GitHub Desktop.
Save jbass86/babf16bf7f474e7920a8baf2056237e2 to your computer and use it in GitHub Desktop.
const userString = "rhinoceros";
const newString = [];
for (let letter of userString) {
console.log("letter is " + letter);
console.log("code is " + letter.charCodeAt(0));
//this is just going to check for lower case
if (letter.charCodeAt(0) < "n".charCodeAt(0) || letter.charCodeAt(0) > "z".charCodeAt(0)) {
newString.push(letter);
}
}
let finalString = newString.join();
//remove the commas from the string join
finalString = finalString.replace(/,/g, "");
console.log("-----------------");
console.log("final string is");
console.log(finalString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment