Skip to main content
added 45 characters in body
Source Link
Alex Kirko
  • 466
  • 3
  • 8

What you need to do is extend the joining condition offered in the answer you sited. Like this:

var combined = [];
function findSecond(iso3, year, second){
    for (var i=0;i = 0; i < second.length; i += 1){
    //Adding the second condition
        if (second[i].iso3 === iso3 && second[i].year ===  year ) {
            return second[i];
        }
    }
    return null;
}

while (el = array1.pop()){
    var getSec = findSecond(el.iso3, el.year, array2);
    if (getSec){
        for (var l in getSec){
            if (!(l in el)) {
                el[l] = getSec[l];
            }
        }
        combined.push(el);
    }
}

What you need to do is extend the joining condition in the answer you sited. Like this:

var combined = [];
function findSecond(iso3, year, second){
    for (var i=0; i < second.length; i += 1){
        if(second[i].iso3 === iso3 && second[i].year ===  year ){
            return second[i];
        }
    }
    return null;
}

while (el = array1.pop()){
    var getSec = findSecond(el.iso3, el.year, array2);
    if (getSec){
        for (var l in getSec){
            if (!(l in el)) {
                el[l] = getSec[l];
            }
        }
        combined.push(el);
    }
}

What you need to do is extend the joining condition offered in the answer you sited. Like this:

var combined = [];
function findSecond(iso3, year, second){
    for (var i = 0; i < second.length; i += 1){
    //Adding the second condition
        if (second[i].iso3 === iso3 && second[i].year ===  year ) {
            return second[i];
        }
    }
    return null;
}

while (el = array1.pop()){
    var getSec = findSecond(el.iso3, el.year, array2);
    if (getSec){
        for (var l in getSec){
            if (!(l in el)) {
                el[l] = getSec[l];
            }
        }
        combined.push(el);
    }
}
Source Link
Alex Kirko
  • 466
  • 3
  • 8

What you need to do is extend the joining condition in the answer you sited. Like this:

var combined = [];
function findSecond(iso3, year, second){
    for (var i=0; i < second.length; i += 1){
        if(second[i].iso3 === iso3 && second[i].year ===  year ){
            return second[i];
        }
    }
    return null;
}

while (el = array1.pop()){
    var getSec = findSecond(el.iso3, el.year, array2);
    if (getSec){
        for (var l in getSec){
            if (!(l in el)) {
                el[l] = getSec[l];
            }
        }
        combined.push(el);
    }
}