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
Post a Comment