I have product codes like: "ABC123", "ABC 8765", "ABC 98761", "ABC89", "TRM 4576", "TRM IKQ", TRM-238", "ERW 78345", "ERW BRB", "ERW 877a" etc etc.
I need JavaScript to return a brand based on three first letters of the product codes. If I include all the product codes on to the JS code, it will become a really long one. What I have done until now, and it is working but:
QUOTE EXAMPLE:
if (PO == "ABC 98761"){
return "Heinisch";
else if (PO == "ABC 87NN"){
return "Heinisch";
else if (PO == "ABC TT5"){
return "Heinisch";
else if (PO == "ABC 6334T"){
return "Heinisch";
else if (PO == "ABC 3543") {
return "Heinisch ";
else if (PO == "RRR J98777"){
return "Reinhart";
else {
return "not known";
UNQUOTE How could I shorten the code so that variable PO starting with ABC would return "Heinisch"? All the product codes starting wit RRR would return Reinhart, etc.
I want my code to be cleaner... Any advise pls?