Array to change Words

Given an array of words: "kate - take" = True "letter - better" = False return an array with all the anagrams grouped together.

by Thomas Orthbandt

HTML

<h3>Given an array of words: 
"kate - take" = True
"letter - better" = False 
return an array with all the anagrams grouped together.
</h3>

JavaScript

// kate = take: true, 
// better = letter: false
var input = "kate, take, letter, better";
var words = input.split(", ");

for (var i = 0; i < words.length; i++) {

  var word = words[i];
  var alpha = word.split("").sort().join("");

  for (var j = 0; j < words.length; j++) {

    if (i === j) {
      continue;
    }

    var other = words[j];
    if (alpha === other.split("").sort().join("")) {
      document.write(word + " - " + other + " (" + i + ", " + j + ")" + "<br>");
    }
  }
}
document.write(words);