Javascript String isAnagramOf(word)

Description

Javascript String isAnagramOf(word)


String.prototype.isAnagramOf = function(word) {
  return this.toLowerCase().sorted() === word.toLowerCase().sorted() && this.toLowerCase() !== word.toLowerCase();
}


String.prototype.sorted = function() {
  return this.split("").sort().toString();
};



PreviousNext

Related