N-Repeated Element in Size 2N Array LeetCode solution in JavaScript
1var repeatedNTimes = function (nums) {2// loop through the array and then as we go over every num we filter that number and get the length. If the length is equal to 1 that is not the element so we continue if its not equal to one its the element we want and we just return that element.34for (let num of nums) {5let len = nums.filter((element) => element === num).length;6if (len == 1) continue;7else return num;8}9};