Skip to content

Instantly share code, notes, and snippets.

@michaelablackham
Created April 9, 2017 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michaelablackham/6fc98a61454de129722f87348421934e to your computer and use it in GitHub Desktop.
Save michaelablackham/6fc98a61454de129722f87348421934e to your computer and use it in GitHub Desktop.
String Drills
function shouter(whatToShout) {
return whatToShout.toUpperCase() + '!!!';
}
/* 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();
function textNormalizer(text) {
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();
function wisePerson(wiseType, whatToSay) {
return 'A wise ' + wiseType + ' once said: "' + whatToSay + '".';
}
/* 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();
@joeljuca
Copy link

Hey Michaela, you can add an extension to the file to have Gist highlight the syntax of your code :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment