Skip to content

Instantly share code, notes, and snippets.

@humphd
Created September 22, 2020 16:15
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 humphd/8eae5c1500910bbc7de7eb90cc517da5 to your computer and use it in GitHub Desktop.
Save humphd/8eae5c1500910bbc7de7eb90cc517da5 to your computer and use it in GitHub Desktop.
WEB222 Week 3 - Strings
let s = "The sky above the port was the color of television, tuned to a dead channel";
function afterComma(value) {
let commaPos = value.indexOf(',');
// No comma found
if(commaPos === -1) {
return value;
}
return value.slice(commaPos + 1).trim();
}
function addPeriod(value) {
return value.endsWith('.') ? value : `${value}.`;
}
console.log(afterComma(s));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment