function solution(A) { // write your code in JavaScript (Node.js 8.9.4) A.sort((a,b) => a-b); let smallest = 1; let i = 0; while(i < A.length) { if (A[i] < smallest) { i++; continue; } if (A[i] === smallest) { smallest++; i++; continue; } break; } return smallest; }