$codility-testCase

by mtambulut

JavaScript

// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');

function solution(A) {
    // write your code in JavaScript (Node.js 8.9.4)
    //let _min = Math.min.apply(null, A);
    let _max = Math.max.apply(null, A);
    _max = _max > 0 ? _max+1 : 1 
    //_min = _min > 0 ? _min : 1
    
    for(let i=1; i < _max; i++){
        if(A.indexOf(i) == -1)
            return i;
    }
    
    return _max;
}