mercredi 1 novembre 2017

JavaScript - returning true even though condition is not fullfilled [duplicate]

This question already has an answer here:

I have the following code:

console.log(usernameExists);
if (usernameExists = true) {
  console.log("returning true");
  return true;
} else if (looped = true) {
  console.log(usernameExists+" is returned");
  looped = null;
  return false;
}

The first console.log(usernameExists) is returning false, but still I am getting a console message of "returning true", and the function in which this is, is returning true! I simply can't figure this out.

Aucun commentaire:

Enregistrer un commentaire