我在我的JavaScript代码中一直收到TypeError。组织代码

时间:2019-06-02 18:16:09

标签: javascript arrays undefined typeerror code.org

此问题与Code.Org有关,我在第30行和第31行进行最终项目时,我的代码未定义,并且收到TypeError

我试图重写整个代码,但仍然无法正常工作。

https://studio.code.org/projects/applab/E5KZ_ROYfuktsDjKIcBdBqFqL-ZJOGpr0SC9TyJG2dI

`

我希望输出显示来自数组和索引的图像,但输出未定义。

这些是控制台中的错误。 警告:行:30:setImageURL()url参数值(未定义)不是字符串。 警告:行:31:setText()文本参数值(未定义)不是uistring。 错误:行:31:类型错误:无法读取未定义的属性'toString'

var allHouses = [];
var allDetails = [];
var addedHouse = {};
var indexHouse = 0;
var indexDetail = 0;
var logged_in = false;
var currentUsername = "";

update();

appendItem(allHouses, "https://feffdecfd6f4b12c966a- 
dac6ac367338c65760efa41c18393ebc.ssl.cf5.rackcdn.com/16300852-parkside- 
estates-standard-1mp51yf-o.jpg");
appendItem(allHouses, 
"https://ap.rdcpix.com/1840429467/977165183f2fd7650ce5f1a378ad03aal-m0xd- 
w1020_h770_q80.jpg");
appendItem(allHouses, 
"https://cdn.tollbrothers.com/communities/12703/images
/002_Toll_9_13_16_Duke_ 
CC_1920.jpg");
update();


appendItem(allDetails, "Address: " + "5713 Blackburn" + "\n" + "Beds: " + 
"4"  + "\n" + "Baths: " + "3.5"  + "\n" + "Price: " + "$429,990" );
appendItem(allDetails, "Address: " + "49110 Manhattan Cir" + "\n" + 
"Beds: " + "4"  + "\n" + "Baths: " + "3.5"  + "\n" + "Price: " + 
"$428,400" );
appendItem(allDetails, "Address: " + "50009 Tahoe Way" + "\n" + "Beds: " 
+ "6"  + "\n" + "Baths: " + "4"  + "\n" + "Price: " + "$608,995" );
update();


function update() {
setText("amountLabel",(indexHouse + 1)+  " of "+ allHouses.length); 
setText("amountLabel",(indexDetail + 1)+  " of "+ allDetails.length); 
setImageURL("imageUser", allHouses[indexHouse]);
setText("detailLabel", allDetails[indexDetail]);
}

0 个答案:

没有答案