console.time('lable')
const nums = [8, 2, 6, 5, 4, 1, 3]
const target = 7
const arr = []
for(let i =0 ;i<nums.length; i++){
for(let j =0 ; j<nums.length -1 ;j++){
if(nums[i] + nums[j] == target){
let obj = {
num1:nums[i],
num2:nums[j]
}
arr.push(obj)
}
}
}
console.timeEnd('lable')
// console.log(arr,'arr')
// console.time('lable')
// function twoNumAdd(arr, target) {
// if (Array.isArray(arr)) {
// // 使用map将遍历过的数字存起来,空间换时间
// let map = {};
// for (let i = 0; i < arr.length; i++) {
// // 从map中查找是否有key 等于 target-nums[i],如果有,则条件成立,返回结果
// if (map[target - arr[i]] !== undefined) {
// return [target - arr[i], arr[i]];
// } else {
// // 条件不成立,将该值存起来
// map[arr[i]] = i;
// }
// console.log(map,'map')
// }
// }
// return [];
// }
// console.timeEnd('lable')
// console.log(twoNumAdd([8, 1, 6, 5, 4, 2, 3],6),'twoNumAdd')
console