I'm trying to make a webpage that when you click on both buttons it'll change the background color, but for some reason that event won't happen unless i change them from the original variable. I think it's because my functions aren't getting and changing my variable's value for some reason but there may be another reason that i can't see. Is there a correct way to change variable values inside functions that i'm not using?
let uno = false;
let dos = false;
function change1() {
uno = true;
return uno;
}
function change2() {
dos = true;
return dos;
}
if (uno && dos) {
document.body.classList.add("change");
}
html,
body {
height: 100%;
width: 100%;
}
body {
margin: 0;
background-color: #8AB0AB;
display: flex;
align-items: center;
justify-content: center;
}
.change {
background-color: #F4D35E;
}
<html>
<body>
<button id="1" onclick="change1()">
#1
</button>
<button id='2' onclick="change2()">
#2
</button>
</body>
</html>