challenge-algorithms-v2.0-w.../08-isAnagram/index.js

22 lines
411 B
JavaScript

export function isAnagram(word1, word2) {
let test = word1.toUpperCase();
let original = word2.toUpperCase();
let tamanho1 = original.length;
let tamanho2 = test.length;
if(tamanho1 !== tamanho2){
return false;
}
let str1 = original.split('').sort().join('');
let str2 = test.split('').sort().join('');
if(str1 === str2){
return true;
}
else{
return false;
}
}