'Is there any simple and easier away to write this javascript condition?

My condition is working, but i believe there is a more elegant and short way to write it:

  if (this.filters.provider.length !== 1) {
    return true
  } else {
    if (this.filters.provider.includes('test')) { return false }
    return true
  }


Solution 1:[1]

you can use a ternary operator like this:

return (this.filters.provider.length !== 1) ? true : this.filters.provider.includes('test') ? false : true;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abhay Kalariya