Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js get each pair of values from an array

function uniquePairs(arr) {
    return arr.reduce((acc, current, i) =>
        [...acc, ...(arr.slice(i + 1).map(val => [current, val]))], []);
}
 
PREVIOUS NEXT
Tagged: #js #pair #values #array
ADD COMMENT
Topic
Name
3+8 =