Initialize first column as true . 0 sum is possible with all elements .
for ( let i = 0 ; i <= n ; i ++ ) { dp [ i ] = new Array ( sum + 1 ) ; for ( let j = 0 ; j <= sum ; j ++ ) { if ( j == 0 ) dp [ i ] [ j ] = true ; } }