forked from M3-Academy/challenge-algorithms-v2.0
feat: Implementa Desafio 2.8
This commit is contained in:
parent
468061254e
commit
b806b8aa33
@ -1,4 +1,18 @@
|
|||||||
export function isAnagram(word1, word2) {
|
export function isAnagram(word1, word2) {
|
||||||
// implementar logica aqui
|
let anagram;
|
||||||
|
|
||||||
|
if(word1.length !== word2.length) {
|
||||||
|
anagram = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let palavra1 = word1.toLowerCase().split("").sort().join("");
|
||||||
|
let palavra2 = word2.toLowerCase().split("").sort().join("");
|
||||||
|
|
||||||
|
if(palavra1 === palavra2) {
|
||||||
|
anagram = true;
|
||||||
|
}else {
|
||||||
|
anagram = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return anagram;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user