Guest User

Untitled

a guest
Apr 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. function wisePerson(wiseType,whatToSay) {
  2. return `A wise ${wiseType} once said: "${whatToSay}".`;
  3. }
  4. const wisePerson2 = (wiseType, whatToSay) => `a ${wiseType} b: ${whatToSay}`;
  5.  
  6. function testWisePerson() {
  7. const wiseType = 'goat';
  8. const whatToSay = 'A bird in the hand is worth 2 in the bush.';
  9.  
  10. const expected = 'A wise ' + wiseType + ' once said: "' + whatToSay + '".';
  11. const actual = wisePerson(wiseType, whatToSay);
  12. if (expected === actual) {console.log('Test Successful')}
  13. else {console.log("Test Failed" + '\n expected:' + expected + '\n actual:' + actual );}
  14. }
  15.  
  16. console.log(wisePerson('goat', 'Hello world'));
  17. console.log(wisePerson2('goat', 'Hello world'));
  18.  
  19. testWisePerson();
  20.  
  21. function shouter(whatToShout) {
  22. return whatToShout.toUpperCase();
  23. }
  24. function testShouter() {
  25. const whatToShout = 'hello Jim!!!';
  26.  
  27. const expected = "HELLO JIM!!!";
  28. const actual = shouter(whatToShout);
  29.  
  30. if (expected === actual) {
  31. console.log('Shouter Test Working');
  32. }
  33. else {
  34. console.log('Shouter Test Failed');
  35. }
  36. }
  37. testShouter()
  38. console.log(shouter('hello Jim!!!'));
  39.  
  40. const textNormalizer = (text) => text.toLowerCase();
  41.  
  42. console.log(textNormalizer('HELLO Jim, THIS is sUper dUper!'));
  43.  
  44. const testTextNormalizer = () => {
  45. const text = 'HELLO Jim, THIS is sUper dUper!';
  46.  
  47. const expected = 'hello jim, this is super duper!';
  48. const actual = textNormalizer(text);
  49.  
  50. console.log( (expected === actual) ? 'TextNormalizer is working' : 'TextNormalizer is failing');
  51. return 0;
  52.  
  53. }
  54.  
  55. testTextNormalizer();
Add Comment
Please, Sign In to add comment