My last element of this weather app is to show a 5 day forecast. Everything was working great, until I decided to use Skycons instead of the written summary. I’m obviously doing something wrong with my For loop because the first icon shows up, and the other 4 days are sadly icon-less. Can you see what I’m doing wrong?
// get weekly forecast
var result = response.daily.data;
for(var i = 0; i < 5; i++) {
var iconForecast = icon[i];
$forecast.append(
"<div class='box'><canvas id='iconForecast' width='28' height='28'></canvas><br>" + Math.round(result[i].temperatureMin)
+ "<br>" + Math.round(result[i].temperatureMax)
+ "</div>"
);
skycons.add("iconForecast", result[i].icon);
skycons.play();
}
When I replace “canvasName” with a static string, e.g. “icon_0”, it displays correctly. I also tried printing “canvasName” and its type to double check it’s being set like I expected, and it’s giving the correct id and showing it as a string. Any idea what could be happening?