I know the object value, How can I return just the object property?

I’m doing this codewars I want return the object property is possible do it when I know the object value ?

function findOdd(A) {
    
        let counter = {};
        let finalResult;

   const NumInt =  A.sort((a, b)=> a - b)

    NumInt.forEach((e)=>{counter[e] = (counter[e] || 0) +1})
    console.log(counter)

    const values = Object.values(counter).filter((value)=>{
        return value % 2 !== 0
    })

    Object.values(counter).filter((value)=>{
       if(value % 2 !== 0){
           return console.log(value)
       }
    })
  }

  findOdd([1,1,2,-2,5,2,4,4,-1,-2,5])

Answer

Using the Object.values() method returns an array of a given object’s own enumerable property values so it’s not what you want in your case.

You can iterate through the for...in statement which iterates over all enumerable properties of an object that are keyed by strings to achieve that.

function findOdd(A) {
    
        let counter = {};
        let finalResult;

   const NumInt =  A.sort((a, b)=> a - b)

    NumInt.forEach((e)=>{counter[e] = (counter[e] || 0) +1})
    console.log(counter)

    const values = Object.values(counter).filter((value)=>{
        return value % 2 !== 0
    })

    for (const el in counter){
       if(counter[el] % 2 !== 0){
           return console.log(el, counter[el]); //logs property name and it's value
       }
    }
  }

  findOdd([1,1,2,-2,5,2,4,4,-1,-2,5])