Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array iteration + find duplicates

function lonelyinteger(a: number[]): number {
   for (let item of a) {
        const items = a.filter(el => item === el)
        if (items.length === 1) {
            return item
        }
    }
}



const a:number[] = [1,2,3,4,3,2,1]

const result:number = lonelyinteger(a);
console.log(result)
Source by practicum.yandex.com #
 
PREVIOUS NEXT
Tagged: #array #iteration #find #duplicates
ADD COMMENT
Topic
Name
7+7 =