I have an array like this from which I am trying to filter out values.
The array is like this:
const arr = [
{
date: "2020-05-18",
values: [
{ name: "a", value: 1 },
{ name: "b", value: 2 }
]
},
{
date: "2020-05-19",
values: [
{ name: "a", value: 3 },
{ name: "b", value: 8 }
]
},
{
date: "2020-05-20",
values: [
{ name: "a", value: 5 },
{ name: "b", value: 6 }
]
}
]
The code is just a function which takes name as an argument and returns the result below.
Code
const result = (name) => {
//return the below result
}
result("b"); //any name could be passed
Result
[
{ date: "2020-05-18", value: 2 },
{ date: "2020-05-19", value: 2 },
{ date: "2020-05-20", value: 6 }
]
How can this be achieved in JS? It would be better, if the output could be achieved using ramda.js
Thanks