AFFILIATE LINKS
Great resource I use to learn algorithms.
40% off Tech Interview Pro: http://techinterviewpro.com/terriblewhiteboard
20% off CoderPro: http://coderpro.com/terriblewhiteboard
Here is the full implementation.
/**
* @param {number[]} nums
* @return {number}
*/
let missingNumber = function(nums) {
let sumIfNoneMissing = nums.length;
let actualSum = 0;
for (let i = 0; i < nums.length; i++){
sumIfNoneMissing += i;
actualSum += nums[i];
}
return sumIfNoneMissing - actualSum;
};