forked from M3-Academy/challenge-algorithms-v2.0
feat: resolucao funcao isAnagram
This commit is contained in:
parent
3e2337919c
commit
27c0c1f894
@ -1,4 +1,20 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user