Skip to content

Instantly share code, notes, and snippets.

@goldtreefrog
Last active October 18, 2017 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goldtreefrog/a9db2869c03dc7b569bccb6a67ed9a4b to your computer and use it in GitHub Desktop.
Save goldtreefrog/a9db2869c03dc7b569bccb6a67ed9a4b to your computer and use it in GitHub Desktop.
'use strict';
function wisePerson(wiseType, whatToSay) {
return `A wise ${wiseType} once said: "${whatToSay}".`
}
console.log(wisePerson("goat","Hello world"));
function shouter(whatToShout) {
return whatToShout.toUpperCase() + "!!!";
}
console.log(shouter('as you can hear i am whispering'));
function textNormalizer(text) {
return text.toLowerCase().trim();
}
console.log(textNormalizer(" let's GO SURFING NOW everyone is learning how "))
/* 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();
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();
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment