var colors=[[255,0,0],[0,255,0]], shades=[]; colors.forEach(function(color,index){ shades[index]=[]; let counter=255; while(counter){ shades[index][counter--]=color.map(function(val){ return !val?val:val-counter; }); }; }); console.log(shades);