I am trying to generate an array of 3 random numbers representing the 3 RGB values using recursion, but getting undefined in the console can you please explain what is the problem and how can I solve it.
const randomColor = (currColor = []) => {
let color = currColor;
color.push(Math.floor(Math.random() * 255 + 1));
if (color.length === 3) return color;
else {
randomColor(color);
}
};
const rc = randomColor();
console.log(rc);