javascript array of objects - redistribute

const current = [
{ studentName: 'Name', ItemNumber: 1, Score: 0 }, 
{ studentName: 'Name', ItemNumber: 2, Score: 1 }]

const needed = [
{ studentName: 'Name', Item1Score: 0, Item2Score: 1 }
]

const names = [...new Set(current.map(v=>v.studentName))]
const items = [...new Set(current.map(v=>v.ItemNumber))].length

How can I convert the current array to the one I need? I know how to get individual student names and the number of items but I don't know how to combine this info in an efficient way to get the needed array.



from Recent Questions - Stack Overflow https://ift.tt/3mIEsau
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Object oriented programming concepts (OOPs)

Spring Webflux : How to return HTTP 200 response with body when the called service returns HTTP 201 without body with WebClient?