Guest User

Untitled

a guest
Jan 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. // Wiseperson generator drill //
  2. /*
  3. function wisePerson(wiseType, whatToSay) {
  4. return `A wise ${wiseType} once said: "${whatToSay}".`;
  5. }
  6. */
  7.  
  8. const wiseType = 'goat';
  9. const whatToSay = 'hello world';
  10. const wiseString = (`A wise ${wiseType} once said: "${whatToSay}".`);
  11.  
  12. function wisePerson(wiseType, whatToSay) {
  13. return wiseString;
  14. }
  15.  
  16. function testWisePerson() {
  17. const wiseType = 'goat';
  18. const whatToSay = 'hello world';
  19. const expected = 'A wise ' + wiseType + ' once said: "' + whatToSay + '".';
  20. const actual = wisePerson(wiseType, whatToSay);
  21. if (expected === actual) {
  22. console.log('SUCCESS: `wisePerson` is working');
  23. } else {
  24. console.log('FAILURE: `wisePerson` is not working');
  25. }
  26. }
  27.  
  28. testWisePerson();
  29.  
  30. // shouter drill //
  31. /*
  32. function shouter(whatToShout) {
  33. return `${whatToShout.toUpperCase()}!!!`;
  34. }
  35. */
  36. const whatToShout = 'fee figh foe fum';
  37. const upperCase = whatToShout.toUpperCase();
  38. function shouter(whatToShout) {
  39. return(upperCase + "!!!");
  40. }
  41.  
  42. function testShouter() {
  43. const whatToShout = 'fee figh foe fum';
  44. const expected = 'FEE FIGH FOE FUM!!!';
  45. if (shouter(whatToShout) === expected) {
  46. console.log('SUCCESS: `shouter` is working');
  47. } else {
  48. console.log('FAILURE: `shouter` is not working');
  49. }
  50. }
  51.  
  52. testShouter();
  53.  
  54. // Text Normalizer Drill //
  55. /*
  56. function textNormalizer(text) {
  57. // chaining together method calls like this is called
  58. // *method chaining*
  59. return text.toLowerCase().trim();
  60. }
  61. */
  62.  
  63. function textNormalizer() {
  64. const text = " let's GO SURFING NOW everyone is learning how ";
  65. const textTrim = text.trim();
  66. const textLowerCase = textTrim.toLowerCase();
  67. return textLowerCase;
  68. }
  69.  
  70.  
  71. function testTextNormalizer() {
  72. const text = " let's GO SURFING NOW everyone is learning how ";
  73. const expected = "let's go surfing now everyone is learning how";
  74. if (textNormalizer(text) === expected) {
  75. console.log('SUCCESS: `textNormalizer` is working');
  76. } else {
  77. console.log('FAILURE: `textNormalizer` is not working');
  78. }
  79. }
  80.  
  81. testTextNormalizer();
Add Comment
Please, Sign In to add comment