This condition will always return true when I try to check string value in Typescript

Solution for This condition will always return true when I try to check string value in Typescript
is Given Below:

I have a phone variable, which is of type number. I need to check if the first two digits are not equal to 33 or 32, so I converted it to string, then stored the first and second digits to perform the comparison.

  let phoneText = this.phone.toString();
  let digit1 = phoneText.charAt(0);
  let digit2 = phoneText.charAt(1);
  let twoDigits: string = digit1+digit2;
  if ( (twoDigits!= "33") || (twoDigits!= "32") ){
    alert("Invalid");
  }

However, I got this error message regarding the if statement, and I don’t understand what the problem is.

This condition will always return 'true' since the types '"33"' and '"32"' have no overlap.ts(2367)
let start: "33"

If number is 32:
First condition is true. You get true.

If number is 0 or any other number:
First condition is true. You get true.

If number is 33:
First condition is false. Second condition is true. You get true.

This is the scenario for which the error exists. Only in this case will the second condition will ever be evaluated. Now at that point you are basically comparing 33 with 32, two values which are different. TS realizes this and gives you the no overlap error.

It is like doing this

let x = true;
if(Math.random() > 0.5 || x == false){
  console.log("hi");
}

What you want is :

  let phoneText = this.phone.toString();
  let digit1 = phoneText.charAt(0);
  let digit2 = phoneText.charAt(1);
  let twoDigits: string = digit1+digit2;
  if ( (twoDigits!= "33") && (twoDigits!= "32") ){
    alert("Invalid");
  }