check if number appears odd number of times in array javascript

// Find the odd int
function findOdd(A) {
  return A.reduce((a, b) => a ^ b);
}

console.log(findOdd([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5], 5)); // 5
console.log(findOdd([1,1,2,-2,5,2,4,4,-1,-2,5], -1)); // -1
console.log(findOdd([20,1,1,2,2,3,3,5,5,4,20,4,5], 5)); // 5

0
7
Awgiedawgie 440220 points

                                    function findOdd(A) {
    let counts = A.reduce((p, n) => (p[n] = ++p[n] || 1, p), {});
    return +Object.keys(counts).find(k => counts[k] % 2) || undefined;
}

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
given an array find the integer that appears an odd number of times javascript how to check if numbers is even or odd in array javascript Given an array of integers, find the one that appears an odd number of times in js count odd number items in array javascript javascript given array of integers find one that appears an odd number of times return odd numbers in array javascript find the one odd or even number out of elements in an array js find the element that appears an odd number of times in an array javascript how to find the count of odd numbers in an array javascript javascript to check if consecutive elements of an array are not odd function that checks array for odd numbers js find odd numbers in an array javascript check number of even number in an array in javascript return number of odd numbers in an array javascript given an array of integers find the one that appears an odd number of times. javascript js array value that appears odd number of times check to see if an array includes an odd number js javascript check odd numbers in array check if only one value is odd in array js check if one value is odd in array js count odd numbers in an array javascript javascript function to count all odd numbers in an array remove odd numbers from array javascript how i display only odd times js Given an array, find the int that appears an odd number of times. There will always be only one integer that appears an odd number of times. search in array javascript how many item that appears an odd number of times. Given an array, find the int that appears an odd number of times. python Given an array, find the int that appears an odd number of times. how to check if a number is repeated odd times in an array in javascript Given an array of integers, find the one that appears an odd number of times Given an array of integers, find the one that appears an odd number of times python given an array, find the integer that appears an odd number of times javascript given an array find the int that appears an odd number of times. javascript Given an array, find the int that appears an odd number of times how do i return the one od number of times in a js aray? Find value that occurs in odd number of elements. js Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. javascript find odd number of integers in an array javascript Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. ruby find odd number times array ruby find number appear an odd number times array ruby find number appear appear an odd number times array ruby find number appear appear an odd number times Given an array of integers, find the one that appears an odd number of times. 'js' find number that appears odd number of time in array javascript Given an array, find the integer that appears an odd number of times. in js find integer appear odd times in an array javascript Given an array, find the integer that appears an odd number of times.There will always be only one integer that appears an odd number of times php Given an array, find the integer that appears an odd number of times.There will always be only one integer that appears an odd number of times find an odd number in list of numbers javascript Given an array, find the integer that appears an odd number of times. check if number appears odd number of times in array javascript
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source