$.ajax({
    url: "https://geolocation-db.com/jsonp",
    jsonpCallback: "callback",
    dataType: "jsonp",
    success: function (location) {
        $("#city-code").html(location.city_code);
    },
});

let getCityCode = location.city_code;

if (getCityCode) {
    bg.innerHTML = `<img src="https://via.placeholder.com/900x450?text=${getCityCode}">`;
} else {
    bg.innerHTML = `<h3>This is not working!</h3>`;
}