DEV Community

ZeeshanAli-0704
ZeeshanAli-0704

Posted on

Missing Number - I

var missingNumber = function(nums) {   
    let length =  nums.length;
    let sortedArray = nums.sort((a,b) => a-b);
    for(let i =0; i <=length; i++){

        if(i !== sortedArray[i]){
            return i;
        }
    }
    return undefined;

};

Enter fullscreen mode Exit fullscreen mode

Top comments (0)