Local Weather Generator Icon Addition

Local Weather Generator Icon Addition


Hi guys. I am trying to put icons from https://codepen.io/joshbader/pen/EjXgqr?editors=0110 into my Local Weather Generator by hiding them and then using Javascript to remove the hide class when the weather corresponds to a particular class. When I remove the hide classes, the icons show. So the fault might be with the javascript GenerateIcon function, but I can’t see anything wrong with it.

You can find my project at: https://codepen.io/mutangeni/pen/qxbPey?editors=1010

Thank you.


Check your browser’s console (Ctrl+Shft+J in Chrome) and you will see the following error:

pen.js:46 Uncaught ReferenceError: text is not defined
at Object.success (VM781 pen.js:46)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest. (jquery.min.js:4)

Line #46 has the following code:

var iconLink = text(data.weather[0].icon);

You have not defined a function called text to do anything, so you get this reference error. Since data.weather[0].icon actually has the icon value in it, you just need to assign it to the iconLink variable.