Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Wiseperson generator drill //
- /*
- function wisePerson(wiseType, whatToSay) {
- return `A wise ${wiseType} once said: "${whatToSay}".`;
- }
- */
- const wiseType = 'goat';
- const whatToSay = 'hello world';
- const wiseString = (`A wise ${wiseType} once said: "${whatToSay}".`);
- function wisePerson(wiseType, whatToSay) {
- return wiseString;
- }
- 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();
- // shouter drill //
- /*
- function shouter(whatToShout) {
- return `${whatToShout.toUpperCase()}!!!`;
- }
- */
- const whatToShout = 'fee figh foe fum';
- const upperCase = whatToShout.toUpperCase();
- function shouter(whatToShout) {
- return(upperCase + "!!!");
- }
- 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();
- // Text Normalizer Drill //
- /*
- function textNormalizer(text) {
- // chaining together method calls like this is called
- // *method chaining*
- return text.toLowerCase().trim();
- }
- */
- function textNormalizer() {
- const text = " let's GO SURFING NOW everyone is learning how ";
- const textTrim = text.trim();
- const textLowerCase = textTrim.toLowerCase();
- return textLowerCase;
- }
- 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();
Add Comment
Please, Sign In to add comment