Range Sum

L1 Easy Arrays & Hashing
Concept
A sub-array is a contiguous slice of an array. Summing a slice from index start to index end is one of the simplest loop patterns.
Given nums, add together every value from index start up to and including index end, and return the total. Both indexes are valid and start is never larger than end.
Examples
▸ nums = [1, 2, 3, 4, 5], start = 1, end = 3
→ 9
▸ nums = [10, 20, 30], start = 0, end = 2
→ 60
▸ nums = [5], start = 0, end = 0
→ 5
Progressive Hints
Hint 1 · Nudge
You don't touch the whole array, only the slice between the two given indexes.
Hint 2 · Plan
Loop over the indexes from start to end inclusive, adding each element to a running total. Return the total.
Hint 3 · Approach
total = 0. For i from start to end (inclusive): total = total + nums[i]. Return total.
Output
// Run your code to see the output here.