Javascript: Ascending sequence

JS: Arrays
Last update: 14 Sep 03:46
0
Students

arrays.js

Write the function that checks if a given increasing sequence of integers is continuous (without gaps). For instance, the [4, 5, 6, 7] sequence is continuous, but the [0, 1, 3] is not. A sequence can start from any number, the only requirement is that no number is skipped. A sequence of one number can't be considered increasing.

Examples

isContinuousSequence([10, 11, 12, 13]);     // true
isContinuousSequence([-5, -4, -3]);         // true

isContinuousSequence([10, 11, 12, 14, 15]); // false
isContinuousSequence([1, 2, 2, 3]);         // false
isContinuousSequence([7]);                  // false
isContinuousSequence([]);                   // false

For full access to the challenge you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests