Given two unsorted arrays , find all pairs whose sum is x | Function to print all pairs in both arrays whose sum is equal to given value x ; Driver code
function findPairs ( arr1 , arr2 , n , m , x ) { for ( let i = 0 ; i < n ; i ++ ) for ( let j = 0 ; j < m ; j ++ ) if ( arr1 [ i ] + arr2 [ j ] == x ) document . write ( arr1 [ i ] + " " + arr2 [ j ] + " " ) ; } let arr1 = [ 1 , 2 , 3 , 7 , 5 , 4 ] ; let arr2 = [ 0 , 7 , 4 , 3 , 2 , 1 ] ; let n = arr1 . length ; let m = arr2 . length ; let x = 8 ; findPairs ( arr1 , arr2 , n , m , x ) ;