Guest User

Untitled

a guest
Dec 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. //=========================
  2. // WISEPERSON GENERATOR |
  3. //=========================
  4. function wisePerson(wiseType, whatToSay) {
  5. return `A wise ${wiseType} once said: "${whatToSay}".`;
  6. }
  7.  
  8. wisePerson('goat', 'hello world');
  9.  
  10. /* From here down, you are not expected to
  11. understand.... for now :)
  12.  
  13.  
  14. Nothing to see here!
  15.  
  16. */
  17.  
  18. // tests
  19.  
  20. function testWisePerson() {
  21. const wiseType = 'goat';
  22. const whatToSay = 'hello world';
  23. const expected = 'A wise ' + wiseType + ' once said: "' + whatToSay + '".';
  24. const actual = wisePerson(wiseType, whatToSay);
  25. if (expected === actual) {
  26. console.log('SUCCESS: `wisePerson` is working');
  27. } else {
  28. console.log('FAILURE: `wisePerson` is not working');
  29. }
  30. }
  31.  
  32. testWisePerson();
  33.  
  34. //==================================================================
  35.  
  36. //=========================
  37. // SHOUTER |
  38. //=========================
  39.  
  40. function shouter(whatToShout) {
  41. return `${whatToShout.toUpperCase()}!!!`;
  42. }
  43.  
  44. shouter('as you can see i am whispering');
  45.  
  46. /* From here down, you are not expected to
  47. understand.... for now :)
  48.  
  49.  
  50. Nothing to see here!
  51.  
  52. */
  53.  
  54. // tests
  55.  
  56. function testShouter() {
  57. const whatToShout = 'fee figh foe fum';
  58. const expected = 'FEE FIGH FOE FUM!!!';
  59. if (shouter(whatToShout) === expected) {
  60. console.log('SUCCESS: `shouter` is working');
  61. } else {
  62. console.log('FAILURE: `shouter` is not working');
  63. }
  64. }
  65.  
  66. testShouter();
  67.  
  68. //==================================================================
  69.  
  70. //=========================
  71. // TEXT NORMALIZER |
  72. //=========================
  73.  
  74. function textNormalizer(text) {
  75. return text.toLowerCase().trim();
  76. }
  77.  
  78. textNormalizer(" let's GO SURFING NOW everyone is learning how ");
  79.  
  80. /* From here down, you are not expected to
  81. understand.... for now :)
  82.  
  83.  
  84. Nothing to see here!
  85.  
  86. */
  87.  
  88. // tests
  89.  
  90. function testTextNormalizer() {
  91. const text = " let's GO SURFING NOW everyone is learning how ";
  92. const expected = "let's go surfing now everyone is learning how";
  93. if (textNormalizer(text) === expected) {
  94. console.log('SUCCESS: `textNormalizer` is working');
  95. } else {
  96. console.log('FAILURE: `textNormalizer` is not working');
  97. }
  98. }
  99.  
  100. testTextNormalizer();
Add Comment
Please, Sign In to add comment