SOURCE

function towSum(nums, target) {
			let result, m;
			for (let i = 0; i < nums.length; i++) {
				m = target - nums[i];
				if (nums.indexOf(m) >= 0 && i != nums.indexOf(m)) {
					result = [i, nums.indexOf(m)];
					break;
				}
			}
			return result;
		}
		const nums = [1, 2, 3, 4, 5, 6];
		const target = 11;
		console.log(towSum(nums, target));
console 命令行工具 X clear

                    
>
console