Skip to content

Instantly share code, notes, and snippets.

@Dodsaren
Last active August 12, 2020 14:06
Show Gist options
  • Save Dodsaren/a346c9f2e745fb3699b58b87895f790b to your computer and use it in GitHub Desktop.
Save Dodsaren/a346c9f2e745fb3699b58b87895f790b to your computer and use it in GitHub Desktop.
function isAnagram(w1, w2) {
if (w1.length !== w2.length) {
return false
}
const a1 = Array.from(w1).sort()
const a2 = Array.from(w2).sort()
for (let i = 0; i < a1.length; i++) {
if (a1[i] !== a2[i]) {
return false
}
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment