Adding Both Ends Together

Published by bangyen in

Given an array of numbers, of any length, create a function which counts how many of those numbers pass the following criteria:

  • The first and last digits of a number must add to 10.

Examples

add_ends([19, 46, 2098]) ➞ 3

add_ends([33, 44, -55]) ➞ 1

add_ends([]) ➞ 0

Notes

  • All items in the array will be numbers.
  • Ignore negative signs (see example #2).
  • If the number contains only one digit, that digit will be the first and the last digit.
  • If given an empty array, return 0.
Watch a quick demo on how Edabit works.