const API_KEY = 'AIzaSyCYYb9Zt3681daQpJ7fvsU-Tm-x_o9rKIkzc';
const API_URL = 'https://maps.googleapis.com/maps/api/geocode/json?';
function makeUrl({ coords }) {
return `${API_URL}latlng=${coords.latitude},${coords.longitude}&key=${API_KEY}&language=en`;
}
export const getGeo = () => {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(makeUrl);
} else {
console.log("Geolocation is not supported by this browser.");
}
}
const array1 = [{ value: '0E1' }, { value: '8B3' }];
const array2 = [
{ code: '0E1', desc: 'Some text' },
{ code: '8B3', desc: 'Some text' },
{ code: '9N8', desc: 'Some text' },
];
const filter = array1.map((el) => el.value);
const result = array2.filter((el) => filter.includes(el.code));
console.log(result);
// Array [ {…}, {…} ]
// 0: Object { code: "0E1", desc: "Some text" }
// 1: Object { code: "8B3", desc: "Some text" }