Codility MissingInteger Javascript solution (proposal)

This afternoon I try to resolve the demo test of Codility. After thinking a lot how to increase the performance (and searching a little bit), I created this code:

function solution(A) {
    let array = [...Array(1000001).keys()];

    const onlyPositives = A.filter(n => n>0);
    if(onlyPositives.length == 0) return 1

    onlyPositives.forEach(a => {
        if(array[a] != null)
            array[a] = null;
    array[0] = null;

   return array.findIndex(e => e != null);

Anyone have another Idea?

130 thoughts on “Codility MissingInteger Javascript solution (proposal)”

  1. 421495 558856Hello. I wanted to ask one thingis this a wordpress web internet site as we are planning to be shifting more than to WP. Furthermore did you make this template yourself? Thanks. 258890