forked from M3-Academy/challenge-algorithms-v2.0
anagrama completo
This commit is contained in:
parent
774737ad5e
commit
fa1db39c47
@ -1,4 +1,24 @@
|
||||
export function isAnagram(word1, word2) {
|
||||
// implementar logica aqui
|
||||
if (word1.length !== word2.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
var str1 = word1.toLowerCase().split("").sort().join("")
|
||||
var str2 = word2.toLowerCase().split("").sort().join("")
|
||||
|
||||
|
||||
var str_resultado = (str1 === str2)
|
||||
return str_resultado
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Resultados esperados
|
||||
console.log(isAnagram("foefet", "toffee"), true) // true
|
||||
console.log(isAnagram("Buckethead", "DeathCubeK"), true) // true
|
||||
console.log(isAnagram("Twoo", "WooT"), true) // true
|
||||
|
||||
console.log(isAnagram("dumble", "bumble"), false) // false
|
||||
console.log(isAnagram("ound", "round"), false) // false
|
||||
console.log(isAnagram("apple", "pale"), false) // false
|
||||
|
Loading…
Reference in New Issue
Block a user