Question: What am I doing wrong? If the button is clicked, variable s will have a value of 10, if not, it's 0. It's not working though. 

```
$('button').observe('click', function () {
  var clicked = true;
  window.clicked = clicked;
});

if (clicked)
{
    var s = 10;
}
else 
{
    var s = 0; 
}

```

Answer: 
This might help you-

```
    <button>
    click
    </button>

<script>
       var clickCounter=0;
        var s=0;
        alert(s);
        $('button').on('click',function(){
          var s=10;
            alert(s);
            });
</script>

```

Initially the variable will store value of 0, after the vutton is clicked the variable is assigned with value of 10.
What exactly are you trying to achieve? Why don't you just set `s = 10` on click event? Like this:

```
var s = 0;

$('button').click(function () {
  s = 10;
  console.log(s);
});

console.log(s);

```

Or, if you're trying to observe the value that changes, try something like this:

```
$('button').click(function () {
  object.s = 10;
});

var object = {};
Object.defineProperty(object, 's', {
  get: function() { 
    return this.value; 
  },
  set: function(newValue) {
    alert(newValue);
    this.value = newValue; 
  }
});

object.s = 0;

```