Test 1

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Test 1
function findOdd(A) {
    for (let i = 0; i < A.length; i++) {
      let count = A.filter(num => num === A[i]).length
      if (count % 2 !== 0) {
        return A[i]
        }
      }  
    }
ready
Test 2
 function findOdd2(A) {
      const count = {}
      for (let num of A) {
        count[num] ? count[num]++ : count[num] = 1
      }
      for (let key in count) {
        if (count[key] % 2 !== 0) {
          return Number(key)
        }
      }
    }
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.