Filter by content Multidimensional array, Functional Programming. JavaScript

0

This time I need to obtain the following purpose, in principle I get an object, which led to a multidimensional array , which I need to take only some depending on its content, the text strings are dates with their value next, I would need to get its date along with its value, for example: only get those for month 09 in this case would be ["09-25", 31.79],[ "09-26", 31.09 ] I'm trying to use functional programming, try to use filter but I do not know how to access each array itself.

let objeto = { "08-15": 31.11, "09-25": 31.79, "09-26": 31.09, "10-01": 30.64, "10-02": 30.77 };

let array = Object.entries(objeto).map(([key, value]) => ([key, value]));

console.log(array);

I appreciate the help you can give me. The other option would be to extract them from the object directly, thanks!

    
asked by Gabriela 02.10.2018 в 23:08
source

1 answer

1

You can apply a filter to your array, using the same arrangement as an example, for example

let objeto = { "08-15": 31.11, "09-25": 31.79, "09-26": 31.09, "10-01": 30.64, "10-02": 30.77 };

let array = Object.entries(objeto).map(([key, value]) => ([key, value]));

var filter=array.filter((o)=>o[0].split('-')[0]=="09");

console.log(filter);
    
answered by 02.10.2018 / 23:26
source