Trouble reading from JSObject created from XML

Turns out, there were some undocumented variables that I needed to account for that no-one informed me on. The corrected code:

let arr = msg.payload; // get the array
let rv = {}; // create a new empty object
let fc = []; 

arr.forEach(obj_payload => {
    if (obj_payload.variable) {
        obj_payload.variable.forEach(obj_variable => {
                let key = obj_variable.$.name;
                if (obj_variable.$.address) {

                    // assign function code depending on D or M (other) prefix
                    if (obj_variable.$.address.indexOf('D') > -1) {
                        fc = 1;
                    } else {
                        fc = 3;
                    }

                    // strip D/M from head of address
                    obj_variable.$.address = obj_variable.$.address.substring(1); 

                    // populate the rest of the JSObject
                    rv[key] = {
                        address: obj_variable.$.address, // addresses, trimmed of letters
                        array_data_type_name: "", // empty
                        fc: fc, // function code
                        quantity: 1, // empty
                        type_name: Object.keys(obj_variable.type[0]).toString(), //object keys
                        word_length: 1, // empty
                        unitid: 255 // previously added by lvc_labels
                    }; // replace arr[i] with selected pieces  
            }
        })
    }
});

msg.payload = rv;
return msg;