The issue im having with my code is that i want it to detect the opposite side of the bracket. I have separated the sides of the brackets into separate objects called rightCount and leftCount. These objects show the number of each of the bracket sides.
If the left side is more than the right, this means that one bracket pair is incomplete and is therefore an invalid bracket. Can someone help me fix my code so it has the ability to detect the brackets? Thank you.

```

const isValid = (parenthesis) => {
    if(typeof(parenthesis) !== "string" ){
        return false
    }
    const countLeft = {}
    const countRight = {}

     //check and see if the number of the 
     //left side is equal to the number of the closing brackets (right side)
        for(let i = 0; i < parenthesis.length; i++){
            if(!countLeft[parenthesis[i]] && parenthesis[i] === "{" || parenthesis[i] === '[' || parenthesis[i] === '(' ){
            countLeft[parenthesis[i]] = 1
            }
            else {
                countLeft[parenthesis[i]]++
            }
        };
        for(let i = 0; i < parenthesis.length; i++){
            if(!countRight[parenthesis[i]] && parenthesis[i] === "}" || parenthesis[i] === ']' || parenthesis[i] === ')' ){
                countRight[parenthesis[i]] = 1
                }
                else {
                    countRight[parenthesis[i]]++
                }
        }

        //The only issue with this is that it cant detect opposite sides of the bracket. It will only search for the same side in the other object
        for(let bracket in countLeft){
            if(countRight[bracket]){
                return true
            }
            else{
                return false
            }
        }

        for(let bracket in countRight){
            if(countleft[bracket]){
                return true
            }
            else{
                return false
            }
        }

        console.log(countLeft) 
        console.log(countRight) 

    }      

```