I'm a newcomer to JavaScript and I'm sure this is very straightforward: I wish to set a number of values based upon a single input in a switch statement. I know in Java I would use getters/setters and or pass the values into an array and pick the relevant field based on its index.
let custCode;
let loyaltyCode;
let id;
const setCustomerCodes = () => {
switch (customerType) {
case "NEW":
(custCode = "19202"), (loyaltyCode = "X78"), (id = "396550");
break;
case "CURRENT":
(custCode = "93893"), (loyaltyCode = "X89"), (id = "396438");
break;
case "LOYAL":
(custCode = "76353"), (loyaltyCode = "X90"), (id = "396440");
break;
default:
(custCode = "02902"), (loyaltyCode = "X80"), (id = "396637");
break;
}
return //all values as an object?;
};
module.exports = {
//export the values to use in separate file
};
I then just want to use the value of each field in a separate JS file. I know this is very basic; easier when I can get my head around debugging in VS Code
return { custCode, loyaltyCode, id }