to return more than one value
let desig
let reqId
const searchRow = data.map(opts => {
desig = opts.value.split(' - ')[0]
reqId = opts.value.split(' - ')[1]
})
console.log("desig", desig)
console.log("reqId", reqId)
to return one value
const objectIds = jobIds.map(id => id._id)
console.log("objectIds", objectIds)
to return arrays
const corporateOptions = result.map(opt => {
opt.Candidate.map(desig => {
desigArray.push(desig.cDesig)
})
opt.Jobdata.map(reqid => {
reqIdArray.push(reqid.reqId)
})
})
to return object arrays
let result = []
filterIntreviews.map((ob) => {
let createObj = {
id: ob.id,
cName: ob.cName,
reqId: ob.reqId,
desig: ob.desig
}
result.push(createObj)
})
console.log("result", result)
To create an array from array object
counterArray [
{ counter: 1 },
{ counter: 2 },
{ counter: 3 }
]
const counters = counterArray.map(ct => ct.counter)
console.log(counters)
output will be => [1, 2, 3]
Top comments (0)