Sum of Missing Numbers

Published by Mubashir Hassan in

Create a function that takes an array of "mostly" numbers and returns the total amount of missing numbers, given that the array is sorted in ascending order. Watch out for strings!

Examples

sumOfMissingNums(["1", "3", "5", "7", "9"]) ➞ 4
// 1+1+1+1

sumOfMissingNums(["7", "3", "1", "9", "5"]) ➞ 4

sumOfMissingNums(["1", "5", "B", "9", "z"]) ➞ 6

Notes

The data might be dirty! Clean out any filthy strings.

Watch a quick demo on how Edabit works.