Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. function wisePerson(wiseType, whatToSay) {
  2. return `A wise ${wiseType} once said: "${whatToSay}".`
  3. }
  4.  
  5. // tests
  6. function testWisePerson() {
  7. const wiseType = 'goat';
  8. const whatToSay = 'hello world';
  9. const expected = 'A wise ' + wiseType + ' once said: "' +
  10. whatToSay + '".';
  11. const actual = wisePerson(wiseType, whatToSay);
  12. if (expected === actual) {
  13. console.log('SUCCESS: `wisePerson` is working');
  14. }
  15. else {
  16. console.log('FAILURE: `wisePerson` is not working');
  17. }
  18. }
  19.  
  20. testWisePerson();
  21.  
  22. function shouter(whatToShout) {
  23. return `${whatToShout.toUpperCase()}!!!`
  24. }
  25.  
  26. // tests
  27. function testShouter() {
  28. const whatToShout = 'fee figh foe fum';
  29. const expected = 'FEE FIGH FOE FUM!!!';
  30. if (shouter(whatToShout) === expected) {
  31. console.log('SUCCESS: `shouter` is working');
  32. }
  33. else {
  34. console.log('FAILURE: `shouter` is not working');
  35. }
  36. }
  37.  
  38. testShouter();
  39.  
  40. function textNormalizer(text) {
  41. return `${text.toLowerCase().trim()}`
  42. }
  43.  
  44. // tests
  45. function testTextNormalizer() {
  46. const text = " let's GO SURFING NOW everyone is learning how ";
  47. const expected = "let's go surfing now everyone is learning how";
  48. if (textNormalizer(text) === expected) {
  49. console.log('SUCCESS: `textNormalizer` is working');
  50. }
  51. else {
  52. console.log('FAILURE: `textNormalizer` is not working');
  53. }
  54. }
  55.  
  56. testTextNormalizer();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement