Iterating through all the prime numbers and check if any of the prime numbers is a factor of the given input array
for ( let i = 0 ; i < allPrimes . length ; i ++ ) { for ( let j = 0 ; j < arr . length ; j ++ ) { if ( arr [ j ] % allPrimes [ i ] == 0 ) { list1 . push ( allPrimes [ i ] ) ; break ; } } } return list1 ; }