The code for mapping laureates to citites in this repo differs from the code in the book:
Book:
const relatedCity = cities.find(city => city.city === laureate.birth_city && city.country === laureate.birth_country);
Repo:
const relatedCity = cities.find(city => city.city === laureate.birth_city) && cities.find(city => city.country === laureate.birth_country);
This is confusing, because the repo code produces wrong results. For example, it maps too many laureates to "New York City", "United States", as it happens to be the first US city in the laureates data set:
- If a city is already known in
cities, relatedCity will be the first city found for the given birth_country, which is NY for US. Therefore, any city in the US other than the first seen has a maximum of 1 laureate. Same is true for any other country. This can be easily verfied on the cities map.
The code for mapping laureates to citites in this repo differs from the code in the book:
Book:
Repo:
This is confusing, because the repo code produces wrong results. For example, it maps too many laureates to "New York City", "United States", as it happens to be the first US city in the laureates data set:
cities,relatedCitywill be the first city found for the givenbirth_country, which is NY for US. Therefore, any city in the US other than the first seen has a maximum of 1 laureate. Same is true for any other country. This can be easily verfied on the cities map.