t
a.forEach(item => {
item.cities.forEach(({ name, country }) => {
if (!countries[country.name]) countries[country.name] = {};
countries[country.name][name] = [item];
});
});
Size: a a a
t
a.forEach(item => {
item.cities.forEach(({ name, country }) => {
if (!countries[country.name]) countries[country.name] = {};
countries[country.name][name] = [item];
});
});
VI
a.forEach(item => {
item.cities.forEach(({ name, country }) => {
if (!countries[country.name]) countries[country.name] = {};
countries[country.name][name] = [item];
});
});
t
a.forEach(item => {
item.cities.forEach(({ name, country }) => {
if (!countries[country.name]) countries[country.name] = {};
if (!countries[country.name][name]) countries[country.name][name] = [];
countries[country.name][name].push(item)
});
});
VI
a.forEach(item => {
item.cities.forEach(({ name, country }) => {
if (!countries[country.name]) countries[country.name] = {};
if (!countries[country.name][name]) countries[country.name][name] = [];
countries[country.name][name].push(item)
});
});
t
t
const checkOutOfCountryExistence = country => countries[country.name] ? '' : countries[country.name] = {};
function addCityToCorrespondingCountry({name, country}) {
checkOutOfCountryExistence(country)
countries[country.name][name] = [];
}
a.forEach({cities} => cities.forEach(addCityToCorrespondingCountry));
VI
const checkOutOfCountryExistence = country => countries[country.name] ? '' : countries[country.name] = {};
function addCityToCorrespondingCountry({name, country}) {
checkOutOfCountryExistence(country)
countries[country.name][name] = [];
}
a.forEach({cities} => cities.forEach(addCityToCorrespondingCountry));
VI
t
VI
t
VI
return Object.entries(a).map(el => Object.entries(el[1]).reduce((acc, val) => {
return acc + val[1].length;
}, 0));
RU
return Object.entries(a).map(el => Object.entries(el[1]).reduce((acc, val) => {
return acc + val[1].length;
}, 0));
VI
RU
DE
return Object.entries(a).map(el => Object.entries(el[1]).reduce((acc, val) => {
return acc + val[1].length;
}, 0));
VI
return Object.values(a).map(el => Object.values(el).reduce((acc, val) => {
return acc + val.length;
}, 0));
MK
return Object.values(a).map(el => Object.values(el).reduce((acc, val) => {
return acc + val.length;
}, 0));
VI
{
Ukraine: {
Kiev: 102,
Odessa: 56
},
Poland: {
Krakov: 3
}
}