Skip to content

Conversation

@roiyraz88
Copy link

No description provided.

</div>
</a>
<section>
<div class="countries-grid" id="countries-list"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need both id and class ?


localStorage.setItem('selectedCountry', JSON.stringify(country));
window.location.href = './details.html';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 - please extract your local storage logic into a service, this way you wont repeat yourself and future changes will only take place in one file

2 - Do not use hardcoded strings, save those into constants

@@ -0,0 +1,78 @@
document.querySelector('.loader').style.display = 'none';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you Do this any way when the file is called why not use css for this?

document.addEventListener('DOMContentLoaded', () => {

const selectedCountry = JSON.parse(localStorage.getItem('selectedCountry'));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, in here this could come from service and do something like this :

  storageService.getItem('selectedCountry')


const countryNativeName = document.createElement('li');
countryNativeName.innerHTML = `<strong>Native Name:</strong> ${selectedCountry.nativeName}`;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not use innerHTML it`s a dangerous method

countryDataList.appendChild(countryCurrencies);
countryDataList.appendChild(countryLanguages);
countryDataList.appendChild(countryBorders);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can save all of those variables into an array and loop the array and add all of those elements

countryCard.appendChild(countryInfo);

countryCard.setAttribute('countryregion', country.region);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a typo in here

Copy link
Member

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove your non used event listners after using them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants