I have a pair of buttons labeled as ok and cancel.
<div class="buttons-div">
<button class='cancel'>Cancel</button>
<button class='ok'>Ok</button>
</div>
The functions I am working with are as follows:
function outerFunc() {
function innerFunc() {
const btns = document.querySelectorAll('.buttons-div')
btns.forEach(btn => {
btn.onclick = (e) => {
if(e.target.classList.contains('cancel')) {
return false;
} else {
return true;
}
}
}
)
}
return innerFunc()
}
const myBoolean = outerFunc()
My goal is to obtain either a true or false value in outerFunc()
upon clicking on one of the two buttons.