我是 JavaScript 新手。
初始数据:
["Argentina", "Maroon 5:50<br>"]
["Australia", "Maroon 5:224<br>"]
["Austria", "Maroon 5:42<br>"]
["Belgium", "Maroon 5:10<br>"]
[""]
["Brazil", "Maroon 5:187<br>"]
[""]
["Canada", "Maroon 5:160<br>"]
[""]
["China", "Maroon 5:10<br>"]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
["France", "Maroon 5:1533<br>"]
我的代码:
$.each(resp.result.artists_detail, function(index, item) {
var arr = [];
var pop_val = [];
var artistdetails="";
for (var i = 0; i < resp.result.artists.length; i++) {
arr.push(item[0].country_name);
if(item[i].play_count != 0){
artistdetails +=item[i].artist_name +':'+ item[i].play_count+'<br>';
}else{
arr.pop(artistdetails);
}
}
arr.push(artistdetails);
arrOfChart.push(arr);
});
我需要这个结果:
["Argentina", "Maroon 5:50<br>"]
["Australia", "Maroon 5:224<br>"]
["Austria", "Maroon 5:42<br>"]
["Belgium", "Maroon 5:10<br>"]
["Brazil", "Maroon 5:187<br>"]
["Canada", "Maroon 5:160<br>"]
["China", "Maroon 5:10<br>"]
["France", "Maroon 5:1533<br>"]
如何删除空白数组?我正在尝试为数组推送添加数组并为数组弹出删除数组,但我需要一个没有空白数组的数组。
慕仙森
慕盖茨4494581
皈依舞
胡子哥哥
相关分类