I have the following code that basically gets some JSON data, looks for the keys with "servergenre", and saves the results in an array. This is a follow up of this question.
let result = [];
Object.keys(data).forEach( key => {
if(/servergenre/.test(key)){
result.push(data[key])
}
});
Even though the code is working correctly, in some editors it raises syntactic errors:
- "key": unsolvable variable or type key
- "=>": expression expected
- "if( / server...": formal parameter name expected
- ")){":
,
expected - "});": statement expected
Here is an image to show you where the errors are:
As I said the code is working fine, I just need it to be fixed or another approach to get rid of the errors.
Furthermore, many compressors and minifiers do not support this bit of code. So I can’t minify it.
Thanks in advance.