Skip to content

Commit

Permalink
Perf(JS) Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka committed Nov 7, 2023
1 parent 5bb6d7f commit d8a9d18
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ async function handleBreedSelection() {
}

function displayCatInfo(catData) {
const cat = catData[0].breeds[0];
const { name, description, temperament, origin, country_code } =
catData[0].breeds[0];

const catImg = catData[0].url;

catInfo.innerHTML = `
<div class="wrapper">
<img class="cat-img" src="${catData[0].url}" alt="Cat image"/>
<img class="cat-img" src="${catImg}" alt="${name}"/>
<div class="wrap">
<h2 class="text">${cat.name}</h2>
<p><b class="primary">Description:</b> ${cat.description}</p>
<p><b class="primary">Temperament:</b> ${cat.temperament}</p>
<p><b class="primary">Country:</b> ${cat.origin}</p>
<img src="https://flagsapi.com/${cat.country_code}/shiny/64.png" alt="Country code" onerror="src='${noImage}'" style="width: 64px;">
<h2 class="text">${name}</h2>
<p><b class="primary">Description:</b> ${description}</p>
<p><b class="primary">Temperament:</b> ${temperament}</p>
<p><b class="primary">Country:</b> ${origin}</p>
<img src="https://flagsapi.com/${country_code}/shiny/64.png" alt="${origin}" onerror="src='${noImage}'" style="width: 64px;">
</div>
</div>
`;
Expand Down

0 comments on commit d8a9d18

Please sign in to comment.