Skip to content
  • Learning paths
  • Challenges
  • Solutions
  • Articles
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 2 years ago

node.js, express.js, ejs, CSS, vanilla JavaScript

express, node
Samuel Adekolu•190
@SamixYasuke
A solution to the REST Countries API with color theme switcher challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


I made use of express.js to read the JSON file and for routing, I also used ejs for the template and vanilla JavaScript to add to search/filter functionality I'd really appreciate your feedback on this project 🙏🏿🙏🏿, thanks.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Saad Hisham•1,770
    @Saad-Hisham
    Posted about 2 years ago

    great work✨ I believe that the project is almost perfect I have a small tip that may help you make it better since the API provides the population as just a number you need to format it with a comma after every number field To format the population numbers returned by the API with commas, we can use regular expressions. Here's an example of how to use regex to add commas to the population number:

    // Convert the population number to a string and replace any non-numeric characters with the letter 's'
    
    const value = country.population.toString().replace(/[^0-9]/g, 's');
    
    // Add commas to the population number at every thousandth place
    const formattedValue = value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
    

    In the first line of code, we convert the population number to a string using toString() and then replace any non-numeric characters with the letter 's' using replace() and a regular expression.

    In the second line of code, we use another regular expression with replace() to add commas to the population number at every thousandth place.

    I hope this explanation is helpful. Keep up the great work🔥

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub