Need help with if-statement to set button disabled

#1

I have this if-statement:

checkFields() {
    if(
      this.customerId != null && 
      this.dealerName != null &&
      this.organizationNumber != null && 
      this.numberOfUsers != null 
    ) {
      this.buttonStatus = false; 
    } else {
      this.buttonStatus = true; 
    }
  }

To me this basically says:

If all fields are filled, then enable the button (disabled = false) 

But even if just one field is filled, the statement sets the buttonstatus to false.

Am I missing something?

All the best

EDIT

Nothing wrong with the above code, I had a typo in another class (of course)

#2

Hello,
filled is not a term in javascript.
foo; // variable is undefined
foo = null; //variable is null
foo = ‘’; //foo contains an empty string.

null means the variable exist but has no type or value.
for debuging to see what your variables are you can check it with an if statement.

Best regards, anna-liebt

#3

Solved it! :slight_smile: It was a typo in my html-class, code above worked just fine after that :smiley: