Below is my nested object.
editedFields {
"TAX_INFORMATION": {
"TAX VALUE INFORMATION": {
"Improvement Value": "$812,57"
}
}
}
const handleValues = (section: string, key: string, value: string | undefined) {
console.log(section) - TAX_INFORMATION
console.log(key) - Improvement Value
console.log(editedFields[section]?.[key]) - undefined
}
I need the output should be the value "$812,57".
Need some valuable help.
2
Answers
You can modify the handlevalue as such
and then call it like this to get $812,57
editedFields[section]?.[Improvement Value] – does not exists in you data.
editedFields[section]?.["TAX VALUE INFORMATION]["Improvement Value"] will give you the data.
If you do not know the mid level key and need to find a specific key in nested object you will need ot right some extra code to get that.
here is a sample of such code.