not sure if the title is misleading or actually is asking what I want: I am trying to get an Object's element value, but the tricky thing is that the element's name is being passed in through a function...
Here is a simplified sample of my code, hope it's clear what I am trying to do
export interface logItem {
id: string
procedure: string
units: string
serviceCode: string
}
function calculateTotalsBasedOnType(
logItems: Array<logItem>
totalsType: string
): totals {
... log.totalsType ...
}
what's the way to go about finding the specific log's element value through the passed in totalsType?
Here is an example method for this
calculateTotalsBasedOnType(logItems, 'serviceCode')
the line log.totalsType
should give me the value of the serviceCode
from the log