请让我知道我做错了什么,以便我可以解决这个问题。我之前有过工作,但改变了一些东西,现在它又被打破了
var myArray = [];
function byId(id) {
return document.getElementById(id);
}
myArray[0] = {
name: "John",
value: "Doe"
};
myArray[1] = {
name: "Jane",
value: "Dew"
};
myArray[2] = {
name: "James",
value: "Dot"
};
myArray[3] = {
name: "Jack",
value: "Dax"
};
//for (var i = 0; i < myArray.length; i++) {
//alert(myArray[i].name + '/' + myArray[i].value);
//}
var text = [],
for (var i=0; i < myArray.length; i++) {
text.push( myArray[i].name + '/' + myArray[i].value);
}
byId("full").innerHTML = text.join('<br/>');
答案 0 :(得分:5)
var text = [],
看到这个逗号?用分号代替:
var text = [];