首先,准备一个数组包含两个对象,如下:javascriptlet arr = [ { name: '张三', Chinese: 80, Math: 90 }, { name: '李四', Chinese: 75, Math: 85 }];接着,使用数组的 forEach 方法遍历数组中的每个对象,为每个对象添加表示总分的属性 'total',总分等于中文和数学的和。javascriptarr.forEach(item => { item.total = item.Chinese + item.Math;});现在,数组中的每个对象都成功地增加了 'total' 属性,表示总分。最终结果如下:javascript[ { name: '张三', Chinese: 80, Math: 90, total: 170 }, { name: '李四', Chinese: 75, Math: 85, total: 160 }]通过使用数组的 forEach 方法,我们能够方便地为数组中的每个对象添加属性,无需逐个对象操作,简化了编程过程。