My Object has a lots of parameter with location, like USA
JAP
...
How to concact my object parameter value with String
variable
Here is my condition:
let loc = '';
if (location === 'USA') {
// the value setting from my Object parameter
// different location with different value
loc = 'usaLocationValue';
} else if (location === 'JAP') {
loc = 'japLocationValue';
} else if() {
// etc...
} else {
// ...
}
// and then filter it
let filterLocationValue = [];
filterLocationValue = MyObjectArray.filter(value => {
return value.loc > 0; // it doesn't work
});
I still try return value.${loc} > 0
(with drop symbol), it doesn't work too.
If I have to set if condition
to decide what parameter to be used first. How to achieve it ?
Any help would be appreciated. Thanks in advance.