Created
September 22, 2020 16:15
-
-
Save humphd/8eae5c1500910bbc7de7eb90cc517da5 to your computer and use it in GitHub Desktop.
WEB222 Week 3 - Strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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