To store the dp values
var dp = Array . from ( Array ( 100 ) , ( ) => Array ( 100 ) ) ; for ( var i = 0 ; i < 100 ; i ++ ) for ( var j = 0 ; j < 100 ; j ++ ) dp [ i ] [ j ] = new Array ( 100 ) . fill ( 0 ) ; function maxProfit ( profit , weight , n , max_W , max_E ) {