Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function doCompare(a, b) {
- let arr = a.split('');
- let arr2 = b.split('');
- for (let i = 0; i < arr2.length; i++) {
- if (arr2[i] == ' ') {
- continue;
- }
- for (let j = 0; j < arr.length; j++) {
- if (arr[j] === arr2[i]) {
- arr.splice(j, 1);
- break;
- }
- if (j + 1 == arr.length) return false;
- }
- }
- return true;
- }
- alert(doCompare('clockwise', 'owe clicks'));
- alert(doCompare('clockwise', 'clockwork'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement