create a variable outside your loop (at the top), ...
# suitescript
a
create a variable outside your loop (at the top), set to 0, then add the totalWeight from each line to it inside the loop