algorithms/find_odd_int/find_odd_int.ts

12 lines
279 B
TypeScript
Raw Permalink Normal View History

2024-01-12 09:36:47 -05:00
export const findOdd = (numbers: number[]): number => {
for (const number of numbers) {
if (numbers.filter(x => x===number).length % 2 !== 0){
return number;
}
}
return 69;
}
const test: number[] = [1,1,2,3,2]
console.log(findOdd(test))