Created
May 27, 2017 07:55
-
-
Save yasirjanjua/64d1fe762925c5e4b1c82f96987aae84 to your computer and use it in GitHub Desktop.
Thinkful Js Drills
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
WisePersonGenerator | |
function wisePerson(wiseType, whatToSay) { | |
// your code here | |
var str = 'A wise ' + wiseType + ' once said: "' + | |
whatToSay + '".'; | |
return str; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testWisePerson() { | |
var wiseType = 'goat'; | |
var whatToSay = 'hello world'; | |
var expected = 'A wise ' + wiseType + ' once said: "' + | |
whatToSay + '".'; | |
var actual = wisePerson(wiseType, whatToSay); | |
if (expected === actual) { | |
console.log('SUCCESS: `wisePerson` is working'); | |
} | |
else { | |
console.log('FAILURE: `wisePerson` is not working'); | |
} | |
} | |
testWisePerson(); | |
---------------------------- | |
Shouter | |
function shouter(whatToShout) { | |
// your code here | |
var str = whatToShout.toUpperCase() + '!!!' ; | |
return str; | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testShouter() { | |
var whatToShout = 'fee figh foe fum'; | |
var expected = 'FEE FIGH FOE FUM!!!'; | |
if (shouter(whatToShout) === expected) { | |
console.log('SUCCESS: `shouter` is working'); | |
} | |
else { | |
console.log('FAILURE: `shouter` is not working'); | |
} | |
} | |
testShouter(); | |
---------------------- | |
Normalizer | |
function textNormalizer(text) { | |
// your code here | |
return text.toLowerCase().trim(); | |
} | |
/* From here down, you are not expected to | |
understand.... for now :) | |
Nothing to see here! | |
*/ | |
// tests | |
function testTextNormalizer() { | |
var text = " let's GO SURFING NOW everyone is learning how "; | |
var 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