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

11 lines
301 B
JavaScript
Raw Normal View History

export function isAnagram(word1, word2) {
// implementar logica aqui
word1 = word1.replace(/[^\w]/g, '').toLowerCase()
word2 = word2.replace(/[^\w]/g, '').toLowerCase()
return sortString(word1) === sortString(word2)
}
function sortString(string) {
return string.split('').sort().join('')
}