how do i sum values in fields?

how do i sum values in fields?

Hi, how can i do to sum 8 fields in a form?

This is how i actually do with 3 fields: 

if(input.field1 > 0) && (input.field2 > 0) && (input.field3 > 0){
      input.total = input.field1 + input.field2 + input.field3;
}

how can i do to simplify the code, cause the example code is for 3 fields, and i need to sum like 8 and And can also add to clutter . and i think it will takes more than 20 if conditions.