Below code changes the color.
Seems like multiple issue
const h1 = document.querySelector('h1');
let r= math.floor((Math.random()+254)+1);
let g= math.floor((Math.random()+254)+1);
let b= math.floor((Math.random()+254)+1);
body.style.backgroundColor(rgb(r,g,b));
h1.innerText(`rgb(${r},${g},${b})`);
- body is not defined
backgroundColor
is not a function
rgb
is not defined
innerText
is not a function
const button= document.querySelector('button');
button.addEventListener('click',function(){
const h1 = document.querySelector('h1');
let r= Math.floor((Math.random()*254)+1);
let g= Math.floor((Math.random()*254)+1);
let b= Math.floor((Math.random()*254)+1);
document.body.style.backgroundColor = `rgb(${r},${g},${b})`;
h1.innerText = `rgb(${r},${g},${b})`;
})
<body>
<h1>Test Color</h1>
<button>Change Color</button>
</body>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…