I’ve been teaching this for a few years, but traversals still cause me problems. I’m trying to build the random forecaster before students get here, and I thought I was on the right path, but I cannot get my filtered list to fill. I went back and looked at the teacher example, and I even asked Gemini, and it said it looks good.
Please help me out. What am I missing?
// Build the Random Forecaster app
var cityList = [(getColumn("Daily Weather", "City"))];
var forecastNumberList = [(getColumn("Daily Weather", "Forecast Number"))];
var filteredCityList = [];
var tomorrowsWeather = "2";
filter();
function filter() {
for (var i = 0; i < 600; i++) {
if (forecastNumberList[i] == tomorrowsWeather) {
appendItem(filteredCityList, cityList[i]);
}
}
console.log(filteredCityList);
}