I'm trying make an anagram check in javascript. For simplicity, assume that the function below only takes lowercase strings without any spacing/numbers/symbols. Why doesn't the code below work?
var anagram = function(string1, string2) {
    var string1array = string1.split('').sort();
    var string2array = string2.split('').sort();
    if (string1array == string2array) {
        console.log("they're anagrams");
    }
    else {
        console.log("they are not anagrams");
    }
}
 
     
     
     
    