Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

done working on countries #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OrYossef
Copy link

No description provided.

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 all of your comment that explain what the code is doing, the code should explain itself

Other than that I left you some comments

@@ -0,0 +1,24 @@
function getCountry() {
document.addEventListener("DOMContentLoaded", () => {
const countryDetails = JSON.parse(localStorage.getItem("countryDetails"));
Copy link
Member

Choose a reason for hiding this comment

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

Couple of things regarding this function :

  1. Make sure that this function is only doing 1 thing, right now the function really overloaded with different things to do
  2. You can extract the localStorage logic into service and call the service methods from there
  3. Do not repeat document.querySelector(".country-flag img"), save this inside a variable, and one more thing that you should do is to style your element via css classes and not js
  4. Do not use innerHTML, it is a dangerous method



fetch('./CountriesData.json')
.then((response) => response.json())
Copy link
Member

Choose a reason for hiding this comment

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

Hardcoded strings should be saved inside constant file, this will enable you to add or change things inside 1 place (Other places might need this string as well)

.catch((error) => console.error('Error fetching countries:', error));

//----------------render the countries function----------------

Copy link
Member

Choose a reason for hiding this comment

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

You don`t need this comment because the name of the function makes it super clear

function renderCountreis(countries){

countriesGrid.innerHTML = '';

Copy link
Member

Choose a reason for hiding this comment

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

Same comment in this function about innerHTML

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