Confirm Background Color
const btn = document.body.appendChild(
document.createElement('button')
)
btn.innerHTML = 'click me'
btn.style.fontSize = '2em'
btn.style.cursor = 'pointer'
btn.addEventListener('click', e => {
if (confirm('Do you want to change the background color?')) {
const deg = Math.random() * 360
document.body.style.backgroundColor = `hsl(${deg}deg, 50%, 50%)`
}
})
Change background color with a call to confirm