SOURCE

var arr=[2,7,6,11,15];
var twoSum = function(nums, target){
    var map = {};
    for(var i = 0; i < nums.length; i++){
        var j = target-nums[i]
        console.log(map[j])
        if(map[j] !== undefined){
          console.log(map)
            return [map[j],i]
        }
        map[nums[i]]=i;
    }
}
document.write(twoSum(arr,9))
console 命令行工具 X clear

                    
>
console