feat(isAnagram): toLowerCase utilizado para retornar as palavras todas minusculas para verificação, if para condicional negativa, split para ordenar a string, join para retornar a string junta

This commit is contained in:
Ramon Dias Ferreira 2022-11-01 22:31:51 -03:00
parent 3bc3385c9f
commit 712c72d45c

View File

@ -1,4 +1,13 @@
export function isAnagram(word1, word2) { export function isAnagram(word1, word2) {
// implementar logica aqui // implementar logica aqui
let word1Lower = word1.toLowerCase()
let word2Lower = word2.toLowerCase()
if (word1Lower.length !== word2Lower.length) {
return false;
}
var string1 = word1Lower.split('').sort().join('');
var string2 = word2Lower.split('').sort().join('');
var result = (string1 === string2);
return result;
} }