Skip to content

Instantly share code, notes, and snippets.

@Daniel-Hug
Created October 13, 2017 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daniel-Hug/76bbe4817ccd556a00aca5d9a33fd432 to your computer and use it in GitHub Desktop.
Save Daniel-Hug/76bbe4817ccd556a00aca5d9a33fd432 to your computer and use it in GitHub Desktop.
JS function: get gaps between numbers
function getGaps(nums) {
var gaps = [];
for (var i = 1; i < nums.length; i++) {
gaps.push(nums[i] - nums[i-1]);
}
return gaps;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment