Say I have four buttons, set out like so:
Click me
(button 1) - Or Click me
(button 2)
option 1
(button 3) - option 2
(button 4)
If I click on button 1 or 2, I want a local variable to be set to which button was pressed.
When I click on either button 3 or 4, I need to access the variable that holds which button was clicked and process it.
I would like to avoid creating variables in the global scope or using more than one. Is this even possible?
What I've Tried:
function setButtonId(i) {
this.id = i
}
setbuttonId.process = item => {
console.log(item)
}
//tmpcode
new
operator.this.id = 1
usereturn {id: 1}
.