FInd the missing number in an array, given n - which is the upper limit of array, array contains numbers 1 - n-1, which means one number is missing.
function missingNum(n, arr) {
var sum = n*(n+1)/2;
for(var i=0; i<arr.length; i++) {
sum -= arr[i];
}
console.log(sum);
return sum;
}
missingNum(5, [4,2,3,5]);