function pairs(target_value, array) { array.map(i => { array.map(j => { (i !== j && array[i] === array[j])? 1 : 0 }) }) } //shorter way to write what you wrote
- function pairs(target_value, array) {
var num_elements = array.length;- array.map(i => { array.map(j => {
- (i !== j && array[i] === array[j])? 1 : 0
- })
- })
- }
for ( var i = 0; i < num_elements; i++ ) {for ( var j = 0; j < num_elements; j++ ) {if ( i !== j && array[i] === array[j] ) {return -1;}}}return 0;}- //shorter way to write what you wrote