1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| function checkImg(code) { let weatherData = +code; const weatherTypes = { isThunderstorm: [15, 16, 17, 18, 21, 22, 33, 34, 35, 36, 41], isClear: [1], isCloudyFog: [25, 26, 27, 28], isCloudy: [2, 3, 4, 5, 6, 7], isFog: [24], isPartiallyClearWithRain: [ 8, 9, 10, 11, 12, 13, 14, 19, 20, 29, 30, 31, 32, 38, 39, ], isSnowing: [23, 37, 42], };
if (weatherTypes.isThunderstorm.includes(weatherData)) { return `<img class="city-icon" src="./img/thunderstorm.png" alt="weather-img">`; } else if (weatherTypes.isClear.includes(weatherData)) { return `<img class="city-icon" src="./img/clear.png" alt="weather-img">`; } else if (weatherTypes.isCloudyFog.includes(weatherData)) { return `<img class="city-icon" src="./img/cloudyfog.png" alt="weather-img">`; } else if (weatherTypes.isCloudy.includes(weatherData)) { return `<img class="city-icon" src="./img/cloud-and-sun.png" alt="weather-img">`; } else if (weatherTypes.isFog.includes(weatherData)) { return `<img class="city-icon" src="./img/fog.png" alt="weather-img">`; } else if (weatherTypes.isPartiallyClearWithRain.includes(weatherData)) { return `<img class="city-icon" src="./img/clearwithrainy.png" alt="weather-img">`; } else { return `<img class="city-icon" src="./img/snow.png" alt="weather-img">`; }
}
|