This function prints all anagram pairs in a given array of strings
function findAllAnagrams ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { if areAnagram ( arr [ i ] , arr [ j ] ) document . write ( arr [ i ] + " " + arr [ j ] ) } } }