2022-10-27 15:07:13 +00:00
|
|
|
export function isAnagram(word1, word2) {
|
2022-10-28 12:16:25 +00:00
|
|
|
let arrayTest = word1.toLowerCase().split('').sort();
|
|
|
|
let arrayOriginal = word2.toLowerCase().split('').sort();
|
|
|
|
|
|
|
|
let palavraTest = arrayTest.toString();
|
|
|
|
let palavraOriginal = arrayOriginal.toString();
|
|
|
|
|
|
|
|
if(arrayTest.length === arrayOriginal.length){
|
|
|
|
if(palavraTest === palavraOriginal){
|
|
|
|
return true
|
|
|
|
}else{
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
return false
|
|
|
|
}
|
2022-10-27 15:07:13 +00:00
|
|
|
|
|
|
|
}
|