[Solved] Convert each array into objects


For each code, you want to map an object. Array.prototype.map is perfect for this kind of treatment.

const codes = ['5', '13', '16', '22', '24'];

const mappedObjects = codes.map(code => {
    return {
        '0': Number(code),
        '1': 'FFFRRR',
        tx: 0,
        ty: 0,
        tz: 0,
        rx: 0,
        ry: 0,
        rz: 0,
    };
});

4

solved Convert each array into objects