const mainebutton = document.querySelector("button");
const body = document.body;
function randomcolorgenerator() {
const red = Math.floor(Math.random() * 256);
const green = Math.floor(Math.random() * 256);
const blue = Math.floor(Math.random() * 256);
console.log(red, green, blue);
const randomcolor = "rgb ${red},${green},${blue}";
return randomcolor;
}
mainebutton.addEventListener("click", () => {
const randomcolor = randomcolorgenerator();
console.log(randomcolor);
});
Uncaught TypeError: Cannot read property of undefined (reading ‘green’)