Created
July 7, 2018 19:42
-
-
Save shravanipl/62fcec7819f3af661f524144c9d6ce62 to your computer and use it in GitHub Desktop.
String assignments
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
function shouter(whatToShout) { | |
const final = whatToShout.toUpperCase(); | |
return `${final}!!!`; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testShouter() { | |
const whatToShout = 'fee figh foe fum'; | |
const expected = 'FEE FIGH FOE FUM!!!'; | |
if (shouter(whatToShout) === expected) { | |
console.log('SUCCESS: `shouter` is working'); | |
} else { | |
console.log('FAILURE: `shouter` is not working'); | |
} | |
} | |
testShouter(); |
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
function textNormalizer(text) { | |
let final= text.toLowerCase().trim(); //trim() removes whitespace | |
return final; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
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(); |
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
function wisePerson(wiseType, whatToSay) { | |
let sent = `A wise ${wiseType} once said: \"${whatToSay}\".`; | |
return sent; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testWisePerson() { | |
const wiseType = 'goat'; | |
const whatToSay = 'hello world'; | |
const expected = 'A wise ' + wiseType + ' once said: "' + whatToSay + '".'; | |
const actual = wisePerson(wiseType, whatToSay); | |
if (expected === actual) { | |
console.log('SUCCESS: `wisePerson` is working'); | |
} else { | |
console.log('FAILURE: `wisePerson` is not working'); | |
} | |
} | |
testWisePerson(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment