How to add values to object as a nested array

Viewed 22

I am creating a function that takes in an array of nested objects as the argument. I want the output to also be an object, and the values to be setup as a nested array. For example:

let input = [
 { dog: 'lab'},
 { dog: 'husky'}
]

function someFunc (arrOfNestedObj) {
 // insert code here
}

I want my output to look like this:

output = {
 dog: ['lab', 'husky']
}

With the problem that I'm working on, my output is displaying the values as strings, and I cannot figure out how to convert to an array OR input the values as an array as I write the function.

0 Answers
Related