Skip to content

Latest commit

 

History

History
6 lines (5 loc) · 361 Bytes

File metadata and controls

6 lines (5 loc) · 361 Bytes

Given an array of integers, return the sum of the first two elements in the array. If the array length is less than 2, sum up the elements that exist, returning 0 if the array is empty.

For example:

  • sum_first_two([1, 2, 3, 4])3 (1 + 2 = 3)
  • sum_first_two([5])5 (since there's only one element)
  • sum_first_two([])0 (empty array)