I'm looking to use lodash to transform an array of objects into an array of strings.
Here is the original array:
const tags = [{
"display": "tag1",
"value": "tag1"
}, {
"display": "tag2",
"value": "tag2"
}]
The expected result is:
const tags = ["tag1", "tag2"]
This is what I have tried so far:
const data = [{
"display": "tag1",
"value": "tag1"
}, {
"display": "tag2",
"value": "tag2"
}]
const result = _(data)
.flatMap(_.values)
.map((item) => { if (typeof item === 'string') { return item; } else { return; } })
.value()
console.log('result', result);