Return true if two strings are anagram using javascript

Anargam

An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.


For example, “Listen” = “Silent”, “evil” = “vile”, “restful” = “fluster”



function anargam(str1, str2){
    if(str1.length !== str2.length) {
        return false
     }
    return str1.toLowerCase().split("").sort().join("") === 
    str2.toLowerCase().split("").sort().join("")
}

console.log(anargam("Listen", "Silent")) //true
console.log(anargam("Hello", "Bye")) //false