Advertisement
natalyayemelyanova

Юлия Чернецкая

Feb 6th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. function compaireStrings(str1, str2) {
  2. let arr1 = str1.toLowerCase().split('');
  3. let arr2 = str2.toLowerCase().split(' ').join('').split('');
  4.  
  5. arr1.sort();
  6. arr2.sort();
  7.  
  8. if (arr1.length !== arr2.length) {
  9. return false;
  10. }
  11.  
  12. for (let i = 0; i < arr1.length; i++) {
  13. if (arr1[i] !== arr2[i]) {
  14. return false;
  15. }
  16. }
  17.  
  18. return true;
  19. }
  20.  
  21. console.log(compaireStrings('clockwise', 'owe clicks'));
  22. console.log(compaireStrings('clockwise', 'clockwork'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement