Help! Javascript comparison with ajax value

Help! Javascript comparison with ajax value
0

#1

Help!!!
I’m trying to change my background color using IF statement, however it always return false when the comparison are basically between “Clouds” == “cloud” which supposedly return true right?
Please help, i have struggled for a couple of hours with this.
Thank you guys!

if (data.weather[0].main == 'cloud') {
    $('body').css('background-color', 'red');
    } else {
     $('body').css('background-color', 'black');
    }

#2

Everything is case sensitive in JavaScript, so you would need to make the following comparison:

if (data.weather[0].main.toLowerCase() == 'cloud') {

FYI - Variable names and functions names are also case sensitive.


#3

Yeayyy finally!
Thank you for the help :smiley: