function renderList() {
    list.empty();
    var tempArray = JSON.parse(localStorage.getItem("cities"));
    if (tempArray !== null) {
        cityArray = tempArray;
    }
    if (cityArray.length > 10) {
        for (var i = cityArray.length - 1; i > cityArray.length - 11; i--) {
            var listItem = $("<li>").text(cityArray[i]).addClass("list-group-item");
            list.append(listItem);
        }
    } else {
        cityArray.forEach(function (city) {
            var listItem = $("<li>").text(city).addClass("list-group-item");
            list.prepend(listItem);
        });
    }
}
// Function to get city array from localStorage and display
Function to get city array from localStorage and display
Function to get city array from localStorage and display
function renderList() {
    list.empty();
    var tempArray = JSON.parse(localStorage.getItem("cities"));
    if (tempArray !== null) {
        cityArray = tempArray;
    }
    if (cityArray.length > 10) {
        for (var i = cityArray.length - 1; i > cityArray.length - 11; i--) {
            var listItem = $("<li>").text(cityArray[i]).addClass("list-group-item");
            list.append(listItem);
        }
    } else {
        cityArray.forEach(function (city) {
            var listItem = $("<li>").text(city).addClass("list-group-item");
            list.prepend(listItem);
        });
    }
}
function renderList ( ) { list . empty ( ) ; var tempArray = JSON . parse ( localStorage . getItem ( "cities" ) ) ; if ( tempArray !== null ) { cityArray = tempArray ; } if ( cityArray . length > 10 ) { for ( var i = cityArray . length - 1 ; i > cityArray . length - 11 ; i -- ) { var listItem = $ ( "<li>" ) . text ( cityArray [ i ] ) . addClass ( "list-group-item" ) ; list . append ( listItem ) ; } } else { cityArray . forEach ( function ( city ) { var listItem = $ ( "<li>" ) . text ( city ) . addClass ( "list-group-item" ) ; list . prepend ( listItem ) ; } ) ; } }
Function to get city array from localStorage and display
Function to get city array from localStorage and display