function fiveDayForcast(location) {
  var requestUrl = "https://api.openweathermap.org/data/2.5/forecast?q=" + location + "&appid=" + key;

  fetch(requestUrl)
    .then(function (response) {
      return response.json();
    })
    .then(function (data) {
      const forecast = document.querySelectorAll(".forecast");
      for (var i = 0; i < forecast.length; i++) {
        forecast[i].innerHTML = "";
        const forecastIndex = i * 8 + 4;
        const forecastDateEl = document.createElement("p");
        var date = new Date(data.list[forecastIndex].dt * 1000);
        const forecastDay = date.getDate();
        const forecastMonth = date.getMonth() + 1;
        const forecastYear = date.getFullYear();
        forecastDateEl.innerHTML = forecastMonth + "/" + forecastDay + "/" + forecastYear;
        forecast[i].appendChild(forecastDateEl);
        const forecastWeatherEl = document.createElement("img");
        forecastWeatherEl.setAttribute("src", "https://openweathermap.org/img/wn/" + data.list[forecastIndex].weather[0].icon + "@2x.png");
        forecastWeatherEl.setAttribute("alt", data.list[forecastIndex].weather[0].description);
        forecast[i].appendChild(forecastWeatherEl);
        const forecastTempEl = document.createElement("p");
        var K = data.list[forecastIndex].main.temp;
        var temperatureVal = ((K-273.15)*1.8)+32;
        temperatureVal = Math.round(temperatureVal * 10) / 10;
        forecastTempEl.innerHTML = "Temp: " + temperatureVal + " &#176F";
        forecast[i].append(forecastTempEl);
        const forecastHumidityEl = document.createElement("p"); 
        forecastHumidityEl.innerHTML = "Humidity: " + data.list[forecastIndex].main.humidity + "%";
        forecast[i].append(forecastHumidityEl);
      }
    });
}
//Function call to get the 5 day weather reports
Function call to get the 5 day weather reports
Function call to get the 5 day weather reports
function fiveDayForcast(location) {
  var requestUrl = "https://api.openweathermap.org/data/2.5/forecast?q=" + location + "&appid=" + key;
  fetch(requestUrl)
    .then(function (response) {
      return response.json();
    })
    .then(function (data) {
      const forecast = document.querySelectorAll(".forecast");
      for (var i = 0; i < forecast.length; i++) {
        forecast[i].innerHTML = "";
        const forecastIndex = i * 8 + 4;
        const forecastDateEl = document.createElement("p");
        var date = new Date(data.list[forecastIndex].dt * 1000);
        const forecastDay = date.getDate();
        const forecastMonth = date.getMonth() + 1;
        const forecastYear = date.getFullYear();
        forecastDateEl.innerHTML = forecastMonth + "/" + forecastDay + "/" + forecastYear;
        forecast[i].appendChild(forecastDateEl);
        const forecastWeatherEl = document.createElement("img");
        forecastWeatherEl.setAttribute("src", "https://openweathermap.org/img/wn/" + data.list[forecastIndex].weather[0].icon + "@2x.png");
        forecastWeatherEl.setAttribute("alt", data.list[forecastIndex].weather[0].description);
        forecast[i].appendChild(forecastWeatherEl);
        const forecastTempEl = document.createElement("p");
        var K = data.list[forecastIndex].main.temp;
        var temperatureVal = ((K-273.15)*1.8)+32;
        temperatureVal = Math.round(temperatureVal * 10) / 10;
        forecastTempEl.innerHTML = "Temp: " + temperatureVal + " &#176F";
        forecast[i].append(forecastTempEl);
        const forecastHumidityEl = document.createElement("p"); 
        forecastHumidityEl.innerHTML = "Humidity: " + data.list[forecastIndex].main.humidity + "%";
        forecast[i].append(forecastHumidityEl);
      }
    });
}
function fiveDayForcast ( location ) { var requestUrl = "https://api.openweathermap.org/data/2.5/forecast?q=" + location + "&appid=" + key ; fetch ( requestUrl ) . then ( function ( response ) { return response . json ( ) ; } ) . then ( function ( data ) { const forecast = document . querySelectorAll ( ".forecast" ) ; for ( var i = 0 ; i < forecast . length ; i ++ ) { forecast [ i ] . innerHTML = "" ; const forecastIndex = i * 8 + 4 ; const forecastDateEl = document . createElement ( "p" ) ; var date = new Date ( data . list [ forecastIndex ] . dt * 1000 ) ; const forecastDay = date . getDate ( ) ; const forecastMonth = date . getMonth ( ) + 1 ; const forecastYear = date . getFullYear ( ) ; forecastDateEl . innerHTML = forecastMonth + "/" + forecastDay + "/" + forecastYear ; forecast [ i ] . appendChild ( forecastDateEl ) ; const forecastWeatherEl = document . createElement ( "img" ) ; forecastWeatherEl . setAttribute ( "src" , "https://openweathermap.org/img/wn/" + data . list [ forecastIndex ] . weather [ 0 ] . icon + "@2x.png" ) ; forecastWeatherEl . setAttribute ( "alt" , data . list [ forecastIndex ] . weather [ 0 ] . description ) ; forecast [ i ] . appendChild ( forecastWeatherEl ) ; const forecastTempEl = document . createElement ( "p" ) ; var K = data . list [ forecastIndex ] . main . temp ; var temperatureVal = ( ( K - 273.15 ) * 1.8 ) + 32 ; temperatureVal = Math . round ( temperatureVal * 10 ) / 10 ; forecastTempEl . innerHTML = "Temp: " + temperatureVal + " &#176F" ; forecast [ i ] . append ( forecastTempEl ) ; const forecastHumidityEl = document . createElement ( "p" ) ; forecastHumidityEl . innerHTML = "Humidity: " + data . list [ forecastIndex ] . main . humidity + "%" ; forecast [ i ] . append ( forecastHumidityEl ) ; } } ) ; }
Function call to get the 5 day weather reports
Function call to get the 5 day weather reports