@arshGoyalDev
Posted
It's great but a few fixes would make it better:
- Title in the navbar should be a link to the home page.
- There are no commas in the population number that make it hard to read you could use regex to fix it
@de-sipher
Posted
@arshWebDev Made some changes. Thank you for your suggestion.
Regarding your comment on commas, how can one go about doing so with regex? Can you perhaps show me an example?
I used Intl.NumberFormat to add commas to the population like so;
return new Intl.NumberFormat('en-EN').format(population)
and this little trick for adding commas to the different languages.
if(index != value.length){
languageList.innerHTML+=','
}
@arshGoyalDev
Posted
@de-sipher Great, I used this regex to solve this issue
data.population.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
And there is an issue like when there is no native name for a country it shows "undefined" you could put a little if check there for undefined cases.
Marked as helpful
@de-sipher
Posted
@arshWebDev Thanks for the code. It's really going to help me since I have to put commas in a lot of websites and I always felt that my way of doing it was a bit cookie-cutter.
As for the undefined error. I did notice it but I just didn't do anything about it yet. I have been debugging this website for several hours every day now and fixed most of the bugs from which I have noticed that, funny enough, debugging was more strenuous and time consuming than implementing the website itself XD. I'll get to it asap though.
Thanks again for the heads-up!
@arshGoyalDev
Posted
@de-sipher That's great, yes debugging takes a lot more time than just making the website.