I'm receiving strings from JSON and need to associate them with an integer. So for example I currently use this method:
var foo = "This is my string";
var bar;
if (foo === "This is my string"){
bar = 3000;
} else if (foo === "Some other string"){
bar = 30001;
}
The problem is that I have ~50 strings I need to associate, and it seems like this huge block of if/else statements can be done in a more efficient way.
Is there any way to make these associations in a more concise and efficient manner?
Cheers