我只是想將以下部分添加到我的代碼中。當我這樣做時,控制臺中不再有任何輸出,并且瀏覽器每次都崩潰。如果我注釋掉該部分,則一切正常。我已經測驗了一切(縮短的回圈運行,更小的資料集,..)但沒有任何幫助。有人有什么想法嗎?
var index_avg_temp_array = []; // array which saves the temperature of each Cluster
index_avg_temp_array.push([]); // creates 2d array
for (id = 0; id < cluster_points; id ) {
// id = index of the cluster
var t_array = []; // create array / set array to 'empty'
var amount = 0;
var check = 0;
// takes the id and check if day_array[].index === id
for (day = 0; day < days_of_year; day ) {
// 365/366 runs, day_array has 1 entry for each day
if (day_array[day].index === id) {
for (hour = 0; hour < 24; hour ) {
// if true - save the hourly temperatures in hour_array
var row = day * 24 hour;
var t_temp = hour_array[row].temp; // temperature of each hour
t_array.push(t_temp);
}
check = 1; // if index was found for at least 1 time
amount = amount 1;
}
}
if (check === 1) {
// check if the index was found for at least 1 time
for (hour = 0; hour < 24; hour ) {
var avg = 0;
for (counter = 0; counter < t_array.length; counter 24) {
var row = hour * 24 counter;
avg = avg t_array[row]; // sum up each hour
}
var avg_hours = avg / amount; // calculate the avg of the hour
index_avg_temp_array[id].push(avg_hours); // save the avg temperatures of each hour for each cluster point
}
}
}
uj5u.com熱心網友回復:
for (counter = 0; counter < t_array.length; counter 24) {
這會導致無限回圈,因為counter永遠不會更新。counter 24應該是counter = 24:
for (counter = 0; counter < t_array.length; counter = 24) {
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/399376.html
標籤:javascript html 调试
