assets/js/script.js
// Adding the city searched to the search history. A maximum of 5 cities to be displayed in the search history
Adding the city searched to the search history. A maximum of 5 cities to be displayed in the search history
Adding the city searched to the search history . A maximum of 5 cities to be displayed in the search history
function addToSearchHistory(searchHistoryArray, searchHistoryCity) {
    if(searchHistoryArray.indexOf(searchHistoryCity) !== -1) {
        searchInput.value = '';
    }
    else {
        if(searchHistoryArray.length < 5) {
            searchHistoryArray
            searchHistoryArray.push(searchHistoryCity);
            renderSearchHistory();
        }
        else {
            searchHistoryArray.shift();
            searchHistoryArray.push(searchHistoryCity);
            renderSearchHistory();
        }
    }
}
function addToSearchHistory ( searchHistoryArray , searchHistoryCity ) { if ( searchHistoryArray . indexOf ( searchHistoryCity ) !== - 1 ) { searchInput . value = '' ; } else { if ( searchHistoryArray . length < 5 ) { searchHistoryArray searchHistoryArray . push ( searchHistoryCity ) ; renderSearchHistory ( ) ; } else { searchHistoryArray . shift ( ) ; searchHistoryArray . push ( searchHistoryCity ) ; renderSearchHistory ( ) ; } } }
Adding the city searched to the search history.
Adding the city searched to the search history .