Advertisement
Guest User

Untitled

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