Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const tests = [
  2.   ' ',
  3.   '  ',
  4.   'aa',
  5.   'aa ',
  6.   ' aa',
  7.   'a b',
  8.   'aa bb',
  9.   'aa  bb',
  10.   'aa   bb',
  11.   'aa    bb',
  12.   'aa   bb   cc',
  13.   '  aa   bb   cc  ',
  14.   '   aa   bb   cc   ',
  15. ];
  16.  
  17. function runTests() {
  18.   for (test of tests) {
  19.     const expected = test.replace(/ +/g, ' ');
  20.     const real = replaceSpace(test);
  21.     if (expected !== real) {
  22.       console.log(`
  23.       test: -${test}-
  24.       expected: -${expected}-
  25.       result: -${real}-
  26.       `);
  27.     }
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement