I have a few json objects (obj1,obj2...) and each is taken from .txt files:
{
"countries": [
{
"Country name": "China",
"Flag": "CN",
"Population": 1395380000,
"undefined": "#688144"
}, ... ]}
and
{
"countries": [
{
"Country name": "India",
"Flag": "IN",
"Population": 1338677000,
"undefined": "#B78A31"
}, ...]}
And so on. Now I want to combine them like this:
{
"countries": [
{
"Country name": "China",
"Flag": "CN",
"Population": 1395380000,
"undefined": "#688144"
},
{
"Country name": "India",
"Flag": "IN",
"Population": 1338677000,
"undefined": "#B78A31"
},
... ]}
So I can loop through data like this:
let obj1 = {}; //saved Data From Txt1;
let obj2 = {}; //saved Data From Txt2
...
let obj = combined?
for (var key in obj.countries) {
var num1 = obj.countries[key].Population+popholder;
if (target >= popholder && target <= num1) {
var country = obj.countries[key]['Country name'];
var testas = document.getElementById("countryname")
}}
How could I achieve this?