How can I push the value return of anonymous function into the array. I have tried with this code but it not work. Where was I wrong
for (var i = 0; i < num; i++) {
//get ramdom color
// arr.push(randomColor());
arr.push(function() {
//pick a "red" from 0 - 255
var r = Math.floor(Math.random() * 256);
//green 0 - 255
var g = Math.floor(Math.random() * 256);
//blue 0 -255
var b = Math.floor(Math.random() * 256);
return "rgb" + "(" + r + ", " + g + ", " + b + ")";
});
}
arr.push(randomColor());?