'Uncaught TypeError: Cannot read property of undefined (reading 'green') [closed]
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')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
