function renderWeatherTable(times, temps, winds, gusts, skies, precipitation) {
const tableBody = document.getElementById("weatherTableBody");
tableBody.innerHTML = "";
times.forEach((time, i) => {
if (i >= temps.length || i >= winds.length || i >= gusts.length || i >= skies.length || i >= precipitation.length) return;
const isHighlighted = shouldHighlightTime(time);
const temperature = temps[i];
const precipChance = precipitation[i];
let precipText = `${precipChance}%`;
let precipIconSrc = "";
let precipAltText = "";
const iconBaseUrl = "https://code.jscharting.com/latest/samples/images/weather-icons/";
if (precipChance > 40) {
if (temperature > 40) {
precipIconSrc = `${iconBaseUrl}rain.svg`;
precipAltText = "Chance of Rain";
} else if (temperature < 34) {
precipIconSrc = `${iconBaseUrl}snow.svg`;
precipAltText = "Chance of Snow";
} else {
precipIconSrc = `${iconBaseUrl}sleet.svg`;
precipAltText = "Chance of Mixed Rain and Snow";
}
if (precipIconSrc) {
precipText = `${precipChance}%
`;
}
}
const skyText = getSkyDescription(skies[i], precipChance, temperature);
const temp = isNaN(temps[i]) ? '' : temps[i];
const wind = isNaN(winds[i]) ? '' : winds[i];
const gust = isNaN(gusts[i]) ? '' : gusts[i];
let row = `
${formatTime(time)}
${temp}°F
${wind}
${gust}
${precipText}
${skyText}
`;
tableBody.innerHTML += row;
});
}
Hourly Weather Forecast
Hourly Weather Conditions
Time | Temp (°F) | Wind (mph) | Gusts (mph) | Precip (%) | Sky |
---|