toLowerCase inside map function

I want to get an image (countryflag) returned right by my country name. The problem is that I get returned iso2 in capital letters and the API only accepts lowercase letters.

As of now the url in the code is returned like: and I need it to return (all lowercase letters) instead.

return (
          { => (
            <li key={d.countryInfo._id}>
              <img src={"" + d.countryInfo.iso2.toLowerCase() + ".png"}></img>
              {} has total {d.cases} different cases as of today.

I have been trying to use .toLowerCase() in the end of d.countryInfo.iso2 (since it’s a String) but then I get TypeError: d.countryInfo.iso2 is null

21 thoughts on “toLowerCase inside map function”

  1. Hi I am so happy I found your web site, I really found you
    by mistake, while I was searching on Yahoo for something else, Nonetheless I am here now and would just like to say cheers for a fantastic post and a all round interesting blog (I also love the theme/design), I don’t
    have time to read it all at the minute but I have bookmarked it and also added your RSS feeds, so
    when I have time I will be back to read much more, Please
    do keep up the fantastic jo.


Leave a Comment