Advertisement
natalyayemelyanova

Роман Песков 5

Mar 15th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. function doCompare(a, b) {
  2.  
  3. let arr = a.split('');
  4. let arr2 = b.split('');
  5.  
  6. for (let i = 0; i < arr2.length; i++) {
  7. if (arr2[i] === ' ') {
  8. continue;
  9. }
  10.  
  11. if (arr.length == 0) return false;
  12.  
  13. for (let j = 0; j < arr.length; j++) {
  14. if (arr[j] === arr2[i]) {
  15. arr.splice(j, 1);
  16. break;
  17. }
  18.  
  19. if (j + 1 == arr.length) return false;
  20. }
  21. }
  22.  
  23. for (let i = 0; i < arr.length; i++) {
  24. if (arr[i] !== ' ') return false;
  25. }
  26. return true;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement