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

14 lines
377 B
JavaScript

export function isAnagram(word1, word2) {
// 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;
}