Find the Missing Number | a represents the array n : Number of elements in array a ; Driver Program
function getMissingNo ( a ) { let n = a . length ; let i , total = 1 ; for ( i = 2 ; i <= ( n + 1 ) ; i ++ ) { total += i ; total -= a [ i - 2 ] ; } return total ; } let arr = [ 1 , 2 , 3 , 5 ] ; document . write ( getMissingNo ( arr ) ) ;