报错:Uncaught TypeError: Cannot read property '1' of undefined
console.log()能访问到数字,为什么比较时就会出错?
<p id="abc">aaaaaa</p>
<script>
var data = [
["北京", 10],
["上海", 20],
["福州", 30],
["广州", 40],
["成都", 40],
["西安", 100]
];
var abc = document.getElementById('abc');
j = 0;
for (var i = 0; i < data.length; i++) {
console.log(data[i][1]);
if (data[i][1] > data[i+1][1]) {
j++;
};
}
abc.innerHTML = j;
</script>
陪伴而非守候
相关分类