var findKthPositive = function(arr, k) { let m = new Map(); for (let i = 1; i <= arr[arr.length-1] + k; i++) m.set(i,1); arr.forEach(num => m.delete(num)); return [...m.keys()][k-1]; }; code example
Example: foreach javascript
Used to execute the same code on every element in an array
Does not change the array
Returns undefined