Hi,

i am working one below challenge

http://codingbat.com/prob/p148138
i was not clear on below description

We have an array of heights, representing the altitude along a walking trail. Given start/end indexes into the array, return the sum of the changes for a walk beginning at the start index and ending at the end index. For example, with the heights {5, 3, 6, 7, 2} and start=2, end=4 yields a sum of 1 + 5 = 6. The start end end index will both be valid indexes into the array with start <= end.

how below results are 6,2, 11 each? please advise

sumHeights([5, 3, 6, 7, 2], 2, 4) → 6

sumHeights([5, 3, 6, 7, 2], 0, 1) → 2

sumHeights([5, 3, 6, 7, 2], 0, 4) → 11

knowing that arrays start with inded 0, index 2 points to the value 6

index 3 is the value of 7

the difference in height is

absolute( 6 - 7 )which is +1in human words: it does not matter if you go uphill or downhill, you perform a walk with a height difference of 1, which is the function of absolute.