How about this solution? If I'm not mistaken, it should fulfill the requirements:

- create a second array
- run through all elements of the input array
- for each number set the respective key in the second array to true
- run through the second array and return the first key which value comes as back `undefined`
- if no match is found, return `1`, so it will work for an empty input array as well

<hr>




    function findNumber(values) {
      let result = [];
      for (let i = 0; i < values.length; ++i) {
        result[values[i]] = true;
      }

      for (let i = 1; i <= result.length; ++i) {
        if (undefined === result[i]) {
          return i;
        }
      }

      return 1;
    }

[Try it yourself](http://jsfiddle.net/bm3s67y1/)