0
At the moment it is only returning if the string to be queried is exactly equal to the key of the object
let estilos = { "alignContent": [ { "ativo": false } ], "alignItems": [ { "ativo": false } ], "alignSelf": [ { "ativo": false } ], "alignmentBaseline": [ { "ativo": false } ], "all": [ { "ativo": false } ], "animation": [ { "ativo": false } ], "animationDelay": [ { "ativo": false } ], "animationDirection": [ { "ativo": false } ], "animationDuration": [ { "ativo": false } ], "animationFillMode": [ { "ativo": false } ], "animationIterationCount": [ { "ativo": false } ], "animationName": [ { "ativo": false } ], "animationPlayState": [ { "ativo": false } ], "animationTimingFunction": [ { "ativo": false } ], "backfaceVisibility": [ { "ativo": false } ], "background": [ { "ativo": false } ], "backgroundAttachment": [ { "ativo": false } ], "backgroundBlendMode": [ { "ativo": false } ] };
const allowed = 'alignContent';
const filtered = Object.keys(estilos)
.filter(key => allowed.match(new RegExp(key, 'g')))
.reduce((obj, key) => {
obj[key] = estilos[key];
return obj;
}, {});
console.log(filtered);
What would be the question?
– Sam
Already solved, I will edit to stay as reference
– Felipe Duarte
Post an answer and edit the question by asking which problem was not posed
– Sam
the solution to the question is not correct... the question is the problem, the solution should be an answer
– Sam
Reverses this last change and adds the answer in the reply box. Then just mark as solved. The person who has a similar doubt, when entering here, will be "lost" without knowing how to do too.
– Valdeir Psr
really, edited
– Felipe Duarte