forked from M3-Academy/challenge-algorithms-v2.0
20 lines
485 B
JavaScript
20 lines
485 B
JavaScript
export function isAnagram(word1, word2) {
|
|
// implementar logica aqui
|
|
|
|
const worldUp1 = /[A-Z]/.test(word1);
|
|
const worldUp2 = /[A-Z]/.test(word2);
|
|
|
|
if(worldUp1 || worldUp2) {
|
|
const str1 = word1.toLowerCase()
|
|
const str2 = word1.toLowerCase()
|
|
const isAnagramStr = ''+[...str1].sort()==[...str2].sort()
|
|
|
|
return isAnagramStr
|
|
} else {
|
|
const isAnagramStr = ''+[...word1].sort()==[...word2].sort()
|
|
|
|
return isAnagramStr
|
|
}
|
|
}
|
|
|
|
isAnagram('roma', 'amor') // true
|