Javascript 谷歌api:信息窗口内容问题

Javascript 谷歌api:信息窗口内容问题,javascript,google-maps,if-statement,google-maps-api-3,google-maps-markers,Javascript,Google Maps,If Statement,Google Maps Api 3,Google Maps Markers,我试图在谷歌地图上显示一个新的地图。在中,我从ajax中获取数据,并设置infowindow的内容 infoWindowContent = [ ['<div class="info_content"><h3>'+ this.tc_city_name + '</h3>'+ if this.tc_city_description !=='null'){ +'<p>' + this.tc_city_descri

我试图在谷歌地图上显示一个新的地图。在中,我从ajax中获取数据,并设置infowindow的内容

infoWindowContent = [
                      ['<div class="info_content"><h3>'+ this.tc_city_name + '</h3>'+ if this.tc_city_description !=='null'){ +'<p>' + this.tc_city_description + '</p>'} + '<p><a href = "' + this.tc_city_web_site + '" target="_blank">' + this.tc_city_web_site + '</a></p>'+ '</div>']
];
这段代码当我使用if条件时,它给出了语法错误,你能告诉我,我如何在这段代码中使用if条件吗

使用+=向变量添加更多内容:

infoWindowContent = '<div class="info_content"><h3>' + this.tc_city_name + '</h3>';

if (this.tc_city_description !== 'null') {
    infoWindowContent += '<p>' + this.tc_city_description + '</p>';
}

infoWindowContent += '<p><a href = "' + this.tc_city_web_site + '" target="_blank">' + this.tc_city_web_site + '</a></p>' + '</div>';

如果某物{infoWindowContent='…';}或者{infoWindowContent='…';}当我对城市名称、描述和网站使用if条件时,它可能会使我的代码变大。请参见下面的答案。
if (condition) { 
    // do something
}