mardi 16 juin 2020

javascript - if is not getting triggered when it should

I have this little snippet of code

             <Calendar
                style=
                eventPropGetter={(event, start, end, isSelected) => {
                  var backgroundColor = "#000000";
                  console.log(event.estado);
                  console.log(isSelected);
                  if (event.estado === 0 && isSelected === false)
                    console.log("here");
                  if (event.estado === 0 && isSelected === true)
                    backgroundColor = "#4d4dff";
                  if (event.estado === 2 && isSelected === true)
                    backgroundColor = "#ff8c1a";
                  if (event.estado === 2 && isSelected === false)
                    backgroundColor = "#b35900";
                  return { style: { backgroundColor } };
                }}

console.log(event.estado) spits out 0

console.log(isSelected) spits out false

however, console.log("here") is never triggered. As I'm new to JS, I'm assuming there's some quirkiness in how JS evaluates truthiness that I'm not aware about Any help would be appreciated

Aucun commentaire:

Enregistrer un commentaire