I have created method in typescript where I pass in a string value as a param. I wanted to include an exception handler where if the 'transactionType' does not equal either 'ADD' or 'REMOVE', then throw an exception.
However, it throws an exception event through I am including the correct param value and I am not sure why that is.
Method examples:
await cashPage.completeAddRemove('ADD');
await cashPage.completeAddRemove('REMOVE');
In that method I attempted both of the following but not working:
async completeAddRemove(transactionType: string) {
if (transactionType != 'ADD' || 'REMOVE') {
throw new Error(`Unrecognised transaction type provided`);
}
async completeAddRemove(transactionType: string) {
if (transactionType !== 'ADD' || 'REMOVE') {
throw new Error(`Unrecognised transaction type provided`);
}