Skip to content

Instantly share code, notes, and snippets.

@michelleroth
Created November 10, 2016 02:34
Show Gist options
  • Save michelleroth/4bc031157deb7a7afe7471b96c863dfc to your computer and use it in GitHub Desktop.
Save michelleroth/4bc031157deb7a7afe7471b96c863dfc to your computer and use it in GitHub Desktop.
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();
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) {
// chaining together method calls like this is called
// *method chaining*
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