-
Notifications
You must be signed in to change notification settings - Fork 30
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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")); |
There was a problem hiding this comment.
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 :
- Make sure that this function is only doing 1 thing, right now the function really overloaded with different things to do
- You can extract the localStorage logic into service and call the service methods from there
- 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 - Do not use
innerHTML
, it is a dangerous method
|
||
|
||
fetch('./CountriesData.json') | ||
.then((response) => response.json()) |
There was a problem hiding this comment.
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---------------- | ||
|
There was a problem hiding this comment.
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 = ''; | ||
|
There was a problem hiding this comment.
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
No description provided.