Right now since there was only a few values I had to total in an array I just did it the long way:
ex: sum of all hours worked in a work week stored in an array( of 5)
totalHours = hours[0] + hours[1] + hours[2] + hours[3] + hours[4]
Any shorter way to do this? I was fortunate enough to only have an array of 5 elements, however I know I should plan for cases of any variable length.
ex: sum of all hours worked in a work week stored in an array( of 5)
totalHours = hours[0] + hours[1] + hours[2] + hours[3] + hours[4]
Any shorter way to do this? I was fortunate enough to only have an array of 5 elements, however I know I should plan for cases of any variable length.
