I am having an issue with my JS code.
I keep getting the following error
Uncaught TypeError: Cannot read property 'appendChild' of null
JS Code:
const weatherIcon = document.getElementById('weather-icon');
const icon = document.createElement('img');
icon.setAttribute('id', 'icon');
icon.src = "http://openweathermap.org/img/w/50n.png";
console.log(icon);
weatherIcon.appendChild(icon); //error is on this line
<div id="weather-data">
<div id="weather-icon">
</div>
</div>