JSFiddle - React, Tailwind, and code Playground

by oktaviardi pratama

JavaScript

function anagram(strA, strB) {
	strA = strA.replace(/[^w]/g, '').toLowerCase()
  strB = strB.replace(/[^w]/g, '').toLowerCase()
  
  return sort(strA) === sort(strB)
}

function sort(txt) {
	return txt.split('').sort().join()
}

console.log(anagram('ate','tea'))