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

17 lines
380 B
JavaScript
Raw Normal View History

2022-11-02 14:59:41 +00:00
export function isAnagram(word1, word2)
for (let index = 0; index < array.length; index++)
{const element = array[index];
{
}
2022-11-02 14:59:41 +00:00
function isAnagram(word1, word2) {
const retorne = word => word
.toLowerCase()
.replace(/[^a-z0-9]/gi, '')
.split('')
.sort()
.join('');
return retorne(word1) === retorne(word2);
}