input [2,3,7,9] because 3 + 7 = 10, output => true
input [4,7,9,10] output => false
input [1,2,3,5] output => false
How can I do this?
Tested with [2,3,7,9], [4,7,9,3] and [1,2,3,5]
function abc(array) {
let output = false;
for (let index = 0; index < array.length; index++) {
const element = array[index];
for (let y = 0; y < array.length; y++) {
if (index === y) continue;
const yElement = array[y];
if (element + yElement === 10) {
output = true;
break;
}
}
if (output) break;
}
return output;
}