I am having an issue understanding variable scope. I have illustrated an example below explaining my issue. Assume I have a bunch of div's with the class .btn and each of them have a unique ID stored in data-id. 

When a div is clicked, I would like to call myFunction with a string passed into it, so it can be used in the function. The issue I run into is that when I define a variable in the function that I want to be conditional based on $(this) of the click function, the called function says it's not define

I understand that it isn't defined in the called function, but I am not sure how to solve this solution

See codepen: <http://codepen.io/anon/pen/rlFyu>

```
function myFunction(data) {
  var a = $(this).attr('data-id');
  console.log(a);
  return data;
}

$('.btn').click(function(){
  myFunction('variable');
});

```