I have a Javascript object with a few sections; namely, banking
,fitment
,personal_info
,vehicle
.
The object is structured as follows:
{
banking: {
account_number: null,
account_type: null,
bank_name: null,
debit_day: null
},
fitment: {
date: null,
terms: null
},
personal_info: {
email: null,
IDNumber: null,
mobile: null,
name: null,
residential_address: null,
surname: null,
title: null,
work_address: null,
work_tel: null
},
vehicle: {
brand: null,
colour: null,
model: null,
registration: null,
vin: null,
year: null
}
}
By default, all values within the object and its “nested sections” have a value of null
.
I’m trying to figure out a way to categorize the sections into 3 different categories, namely:
empty, partial and complete.
“empty” being a case that all values within a section are set as null
.
“partial” being that some values within a section have been set (not all null
)
“complete” being that no values within a section are set to null
. All have values.
My first attempt was with utilizing the Underscore library with _.some()
, however I can’t seem to wrap my head around catering for all 3 category scenarios.
Some help and guidance will be much appreciated.
Thanks!