forked from M3-Academy/challenge-algorithms-v2.0
feat(isAnagram): adicionando resolucao desafio 8
isAnagram
This commit is contained in:
parent
a51c45d47c
commit
78aaef7f2f
@ -1,4 +1,13 @@
|
|||||||
export function isAnagram(word1, word2) {
|
export function isAnagram(word1, word2) {
|
||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
|
let array = word1.toLowerCase().split('').sort();
|
||||||
|
let array2 = word2.toLowerCase().split('').sort();
|
||||||
|
|
||||||
|
if (word1.length !== word2.length) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (array.toString() === array2.toString()) {
|
||||||
|
return true;
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user