I have two array objects which is of different lengths in which data.rows
is of length 955 and place_names
is of length 287. I am running loop inside the loop which takes around 3 minutes to run. Is there any easy and fastest way to run the code below?
for (i = 0; i < place_names.length; i++) {
for (j = 0; j < data.rows.length; j++) {
if (place_names[i].name === data.rows[j].name) {
geom.push(data.rows[j].st_asgeojson);
geom1.push({
name: data.rows[j].name,
geometry: data.rows[j].st_asgeojson
});
matched_average_value.push(place_names[i].average);
matched_sum_value.push(place_names[i].sum);
matched_minimum_value.push(place_names[i].minmum);
matched_maximum_value.push(place_names[i].maximum);
}
else {
console.log("no matches found");
}
}
}