challenge-algorithms-v2.0-h.../08-isAnagram/index.js

19 lines
411 B
JavaScript
Raw Normal View History

export function isAnagram(word1, word2) {
// implementar logica aqui
2022-10-28 00:22:41 +00:00
if (!word1 || !word2) return { error: 'Not Found Words' };
function toLowerCase(word) {
return word.toLowerCase();
}
function toSortWord(word) {
return word.split('').sort().join('');
}
function toAnalyzing(word){
return toSortWord(toLowerCase(word))
}
return toAnalyzing(word1) === toAnalyzing(word2)
}