I am working with OR gate logic to compare a few data (LHS) with a common data (RHS).
My logic is currently working fine, but I would like to know if there’s a better approach to do this.
if (data1 == "compareData" ||
data2 == "compareData" ||
data3 == "compareData" ||
data4 == "compareData") {
//// Do Something
}
As you can notice "compareData" is same here.
I’m using JavaScript language with React.
I am looking on something on the line of how IN keyword in SQL works, where you can do this-
SELECT * FROM table_name where col_name IN (data1, data2, data3, data4);
Please note that this is a simplified version of my logic.
Source: Ask Javascript Questions