You would be calling the first function each time the change occurs, and then check against the value of a. Something like this,
function first()
{
var a=10;
if(a == 10) {
second();
}
}
.. to execute the first function on the button click, you can write the
onclick
event in the HTML as,
<button onclick="first()">Button</button>
Did you know, you can directly pass the value from HTML markup to the JavaScript as a parameter too?
<button onclick="first(10)">Button</button>
function first(a) {
if(a == 10) {
second();
}
}