I'm using the script below to detect city and state from geo.js, but sometimes city comes back as 'undefined' because city is not returned in the array response. How can I detect if json.city is undefined and show something else in "citybody" if city is not detected?
<script async src="https://get.geojs.io/v1/ip/geo.js"></script>
<script type="application/javascript">
        function geoip(json){
        var userip      = json.ip;
    var city      = json.city;
    var region      = json.region;
    
    console.log (json.city);
    console.log (json.region);
    console.log (json.ip);
    
    document.getElementById("city").innerHTML = json.city ;
    document.getElementById("region").innerHTML = json.region ;
    document.getElementById("citybody").innerHTML = json.city ;
    document.getElementById("regionbody").innerHTML = json.region ;
    document.getElementById("region3").innerHTML = json.region ;
 }   
</script>I've tried using json.city != 'undefined' but does not work.
