Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

codewars js Find the first non-consecutive number

function firstNonConsecutive(arr) {
  for (let i = 0; i < arr.length - 1; ++i) {
    if (arr[i] + 1 !== arr[i + 1]) {
      return arr[i + 1]
    }
  }
  return null
}
 
PREVIOUS NEXT
Tagged: #codewars #js #Find #number
ADD COMMENT
Topic
Name
4+3 =