I Have two objects booking and History. I have to check booking userId matches with History userId or History CustomerID
If booking userId matches with any of these two fields(History userId or History CustomerID) we should return “ID matched” in the console.
If booking userId does not match with any of these two fields(History userId or History CustomerID). we should return “ID not matched with booking”.
Below is my code .its working as expected but is this a better approach? or i can do this in some other way
Please suggest
var booking = {"userId":"1233","CustomerID":null,"username":"av"};
var History = {"userId":"123","CustomerID":null,"username":"av"};
var a = booking.userId != History.userId;
var b = booking.userId == History.CustomerID;
var c = booking.userId == History.userId;
var d = booking.userId != History.CustomerID;
console.log(a)
console.log(b)
console.log(c)
console.log(d)
if( a && !b || c && !d)
{
console.log("ID not mathced with booking ")
}else{
console.log("ID mathced")
}