你的评论
Hello John,
I am unsure if this is any better but I just attempted to break out some of the functionality into separate functions
const calcOcKeyNum = (numberPresent) => {
let ocTemp = 0
if(numberPresent !== null){
let temp = parseInt(numberPresent[0])
ocTemp = temp !== null ? temp : -1
}
return ocTemp;
}
const sortInputIntoObjects = (_inputData) => {
let subkey = [];
// const tempArr = [];
let ContactObj = {}, OtherContact = {}, Company = {}, Custom = {};
const addToObject = (obj) => obj[subkey[1]] = _inputData[key];
for (key in _inputData) {
subkey = key.split('__');
switch (subkey[0]) {
case 'Contact': {
addToObject(ContactObj);
break;
}
case 'OtherContact': {
addToObject(OtherContact)
//ignore, still trying to figure out what to do with extra contacts
// let ocKeyNum = calcOcKeyNum(subkey[0].match(REGEX_NUMBER))
// tempArr[ocKeyNum] = OtherContact[subkey[1]];
break;
}
case 'Company': {
addToObject(Company);
break;
}
default: {
addToObject(Custom);
}
}
}
};
UserEcho 的客户支持
I know this thread wasn't for my code but thank you for the feedback on my response.