JavaScript Anagram checker
Your function has a high complexity because of the 2 nested loops.

Here is my implementation. I'm not sure if it's more efficient, but I think it's more readable.

function findAndAppendCharacter(countArray, currentChar) {
    let foundAt = -1

    countArray.forEach((pair, i) =&gt; {
        if(pair.letter == currentChar) {
            foundAt = i
        }
    })


    if(foundAt == -1) {
        countArray.push({
            letter: currentChar,
            count: 1
        })

        return
    }

    countArray[foundAt].count++
}

function findAnagram(firstWord, secondWord) {
    firstWord = firstWord.replace(" ", "")
    secondWord = secondWord.replace(" ", "")

    if(firstWord.length != secondWord.length) {
        return "Not an anagram!"
    }

    let letterCountArray = {
        first: [],
        second: []
    }

    for(let i = 0; i &lt; firstWord.length; i++) {
        findAndAppendCharacter(letterCountArray.first, firstWord.charAt(i).toLowerCase())
        findAndAppendCharacter(letterCountArray.second, secondWord.charAt(i).toLowerCase())
    }


    if(letterCountArray.first.length != letterCountArray.second.length) {
        return "Not an anagram!"
    }

    for(let i = 0; i &lt; letterCountArray.first.length; i++) {
        let firstPair = letterCountArray.first[i]
        let secondPair = letterCountArray.second[i]

        if(letterCountArray.first.filter(pair =&gt; pair.letter == secondPair.letter &amp;&amp; pair.count == secondPair.count).length != 1) {
            return "Not an anagram!"
        }

        if(letterCountArray.second.filter(pair =&gt; pair.letter == firstPair.letter &amp;&amp; pair.count == firstPair.count).length != 1) {
            return "Not an anagram!"
        }
    }

    return "Anagram!"
}


I'm also curious about a better solution :)