-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
32 lines (25 loc) · 1.02 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const countriesContainer = document.querySelector(".countriesContainer")
fetch('./countries.json')
.then((res) => res.json())
.then((data) => {
// console.log(data)
data.forEach(country => {
// console.log(country)
const countryCard = document.createElement('a');
countryCard.href = `country.html?name=${country.name.common}`;
countryCard.classList.add('country');
// const cardImage = document.createElement('img');
// cardImage.src = 'https://flagcdn.com/is.svg';
// countryCard.append(cardImage);
countryCard.innerHTML = `
<img src="${country.flags.svg}">
<div class="cardText">
<h3 class="cardTitle">${country.name.common}</h3>
<p><b>Population: </b>${country.population.toLocaleString('en-IN')}</p>
<p><b>Region: </b>${country.region}</p>
<p><b>Capital: </b>${country.capital}</p>
</div>
`;
countriesContainer.append(countryCard)
});
})