fork download
  1. // your code goes here
  2.  
  3. const increasingSequence = (arr) => !arr.some((val, idx) => val != arr[0] + idx);
  4.  
  5. var arr1 = [1, 2, 3, 4];
  6. var arr2 = [1, 2, 4, 5];
  7. var arr3 = [-4, -3, -2, -1];
  8. var arr4 = [-4, -3, -1, 0];
  9. var arr5 = [4, 3, 2, 1, 0];
  10.  
  11. print(increasingSequence(arr1)); // true
  12. print(increasingSequence(arr2)); // false
  13. print(increasingSequence(arr3)); // true
  14. print(increasingSequence(arr4)); // false
  15. print(increasingSequence(arr5)); // false
  16.  
Success #stdin #stdout 0.01s 10860KB
stdin
Standard input is empty
stdout
true
false
true
false
false