Lets say we have a Product object with Product.Name, Product.Desc, and Product.Price
but for reasons beyond our control we might recieve a product object with lowercase variables (Product.name, Product.desc, Product.price)
is there a way to interpret variables that are not case sensitive? Or do I have to do some regex .toLowerCase() magic?
Thoughts?
I like Alex Filatov's solution (+1). Yet, sometimes the name variations are known in advance and/or you may want to accept only certain variations. In this case I've found it easier to do this:
Product.Name = Product.Name || Product.name || default.Name;
Just OR the acceptable name variations and optionally add a default value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With