function add() {
let nums = [2, 5, 5, 6, 1];
let k = 10;
let tempNum;
for (key in nums) {
tempNum = k - nums[key];
if (nums.find((elem,index) => elem === tempNum&&key!==index)) {
return true;
}
}
return false;
}
网友评论