Is there a way to concatenate two arrays in Ramda.js?
Here is the data I am working with:
const inputData = {
content: [
{
info: ['Test-1-1', 'test-1-2'],
moreInfo: ['foo', 'bar'],
firstName: 'first',
lastName: 'lst',
notes: 'Some info goes here'
},
{
info: ['Test-2-1', 'test-2-2'],
moreInfo: ['foo-2', 'bar-2'],
firstName: 'first',
lastName: 'lst',
notes: 'Some info goes here-2'
},
]
}
I can manipulate this data easily, but I am struggling to merge two arrays together.
What I want to achieve is combining:
info: ['Test-2-1', 'test-2-2'],
moreInfo: ['foo-2', 'bar-2'],
And returning:
"theInfo": ["Test-1-1", "test-1-2", "foo", "bar"]
This is the code I have so far:
const allInfo = (R.props(['info', 'moreInfo']));
const returnNewObject = R.applySpec({
// More code here to do other stuff
theInfo: allInfo,
})
R.map(returnNewObject, inputData.content)
The result I am getting is:
{
// other info
"theInfo": [["Test-1-1", "test-1-2"], ["foo", "bar"]]
}
I have attempted to use the example from the documentation:
- use example from documentation
R.concat([4, 5, 6], [1, 2, 3]);
However, it returns an array of empty objects. It seems to not work as expected based on the documentation