In certain situations, it may happen that we have undefined or generally falsy values in Array structures. For instance when reading and filling data f
var a = ["3","", "6"];
var b = [23,54,56];
var result = [];
for (var i=0;i<a.length;++i) {
if (a[i] != "") {
result[i] = b[i];
}
}
result = result.filter(function( element ) {
return element !== undefined;
});
console.log(result);