Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var isAnagram = function (test, original) {
- if (original.length !== test.length) {
- return false;
- }
- let matches = 0;
- test = test.toUpperCase();
- original = original.toUpperCase();
- original = original.split('');
- test = test.split('');
- for (let i = 0; i < original.length; i++) {
- for (let j = 0; j < test.length; j++) {
- if (original[i] === test[j]) {
- test.splice(j, 1);
- matches++;
- }
- }
- }
- if (matches === original.length) {
- return true;
- } else {
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement