Weather API - Feedback


I had just finished my weather API.

I’m actually using 2 APIs, one to determine the local weather, while the other is to determine weather by zip code.

Please let me know how I can improve the code and it’s organization. I’m not sure if my approach to setting the background image is even a good practice – using the .includes() method.

Thanks in advance!

That seems like a lot of includes and that is not even all the possible weather conditions that can be returned from that API.

Below is another possible solution using just one include. There are

    var backgroundImage = function(desc){
      desc = desc.toLowerCase();
      var conditionBGs = {
        clear: '',
        cloud: '',
        rain: '',
        sun: '',
        snow: ''
      var bg; // would be good to assign a default image in case a desc does not match any of the above
      for (condition in conditionBGs) {
        if (desc.includes(condition)) {
          bg = conditionBGs[condition];
      $("body").css("background-image", "url(" + bg + ")");

Also, what if it is night and the description is Clear? Do you really want to show a sunny sky?