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

18 lines
489 B
JavaScript

export function isAnagram(word1, word2) {
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
}
}