I am working with JSON data that is being displayed in a pop-up on a map. In cases where there is missing data (Visibility), the word undefined appears in the pop-up.
Is there a way to remove the undefined text so that it does not show up in the pop-up?
This is the JSON data:
[{
"date":"03-03-2022",
"lat":-5.67,
"lng":80.65,
"weather":"2",
"temperature": "24.4",
"Humidity": "90",
"Wind": "100"}]
This is the JavaScript code:
<script>
for (i = 0; i < dataJSON.length; i++) {
var weather = parseInt(dataJSON[i].weather)
var Coordinate = new L.latLng(([dataJSON[i].lat, dataJSON[i].lng]))
var marker = L.marker(Coordinate, { icon: customIcon })
marker.bindPopup('Date : ' + dataJSON[i].date + 'Temperature : ' + dataJSON[i].temperature + 'RH :' + dataJSON[i].Humidity
+ 'wind :' + dataJSON[i].Wind + 'Visibility :' + dataJSON[i].Vis
)
}
This is how the pop-up looks like:
https://i.stack.imgur.com/oUlEe.png
I would appreciate any help or suggestions. Thank you!