anagrama completo

This commit is contained in:
Mickael_cypriano 2022-11-02 15:54:18 -03:00
parent 774737ad5e
commit fa1db39c47

View File

@ -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