DEV Community

Discussion on: what is the diffrence between these if else condition

Collapse
 
gregorywitek profile image
Gregory Witek

The 2nd condition is equivalent of "or", you can write it like this:

if(values.fname.length < 3 || values.lname.length < 3 ) {
  btnAction = true;
} else {
  btnAction = false;
}

Also, because the expression values.fname.length < 3 || values.lname.length < 3 already returns true or false, you can rewrite this code like this:

btnAction = values.fname.length < 3 || values.lname.length < 3