assets/script.js
// displayForecast - display 5 days of forecasted weather
display 5 days of forecasted weather
display 5 days of forecasted weather
function displayForecast(response) {
    var forecastArr = response.daily;
    for (var i = 1; i < 6; i++) {
        $(`#day${i}`).empty();
        var dateString = moment.unix(forecastArr[i].dt).format("MM/DD/YY");
        var icon = forecastArr[i].weather[0].icon;
        var iconURL = `http://openweathermap.org/img/w/${icon}.png`;
        var iconEl = $("<img>");
        iconEl.attr("src", iconURL);
        $(`#day${i}-date`).text(`${dateString}`); 
        $(`#day${i}`).append(iconEl); 
        $(`#day${i}`).append(`<br>`); 
        $(`#day${i}`).append(`Temp: ${forecastArr[i].temp.max} ${String.fromCharCode(176)}F`); 
        $(`#day${i}`).append(`<br>`); 
        $(`#day${i}`).append(`Humidity: ${forecastArr[i].humidity}%`); 
    }
}
function displayForecast ( response ) { var forecastArr = response . daily ; for ( var i = 1 ; i < 6 ; i ++ ) { $ ( ` ${ i } ` ) . empty ( ) ; var dateString = moment . unix ( forecastArr [ i ] . dt ) . format ( "MM/DD/YY" ) ; var icon = forecastArr [ i ] . weather [ 0 ] . icon ; var iconURL = ` ${ icon } ` ; var iconEl = $ ( "<img>" ) ; iconEl . attr ( "src" , iconURL ) ; $ ( ` ${ i } ` ) . text ( ` ${ dateString } ` ) ; $ ( ` ${ i } ` ) . append ( iconEl ) ; $ ( ` ${ i } ` ) . append ( ` ` ) ; $ ( ` ${ i } ` ) . append ( ` ${ forecastArr [ i ] . temp . max } ${ String . fromCharCode ( 176 ) } ` ) ; $ ( ` ${ i } ` ) . append ( ` ` ) ; $ ( ` ${ i } ` ) . append ( ` ${ forecastArr [ i ] . humidity } ` ) ; } }
displayForecast - display 5 days of forecasted weather
displayForecast - display 5 days of forecasted weather
// console.log(response.daily); // empty html elements // format date // build img element for weather icon // set html elements to display