Skip to content

Instantly share code, notes, and snippets.

@willwalker753
Created February 12, 2020 20:05
Show Gist options
  • Save willwalker753/a4ff3700f151f42233a6b9340a90e341 to your computer and use it in GitHub Desktop.
Save willwalker753/a4ff3700f151f42233a6b9340a90e341 to your computer and use it in GitHub Desktop.
Text normalizer
function textNormalizer(text) {
let normal = text.toLowerCase();
normal = normal.trim();
return normal;
}
let text = " let's GO SURFING NOW everyone is learning how ";
console.log(textNormalizer(text));
function testTextNormalizer() {
const text = " let's GO SURFING NOW everyone is learning how ";
const expected = "let's go surfing now everyone is learning how";
if (textNormalizer(text) === expected) {
console.log('SUCCESS: `textNormalizer` is working');
} else {
console.log('FAILURE: `textNormalizer` is not working');
}
}
testTextNormalizer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment