So I have a good grasp of most static typed languages mainly C and C++. But when I went into javascript I noticed something that bummed me out.

I learned to write this function to interact with inner HTML:

```
document.getElementById("SomeHTML").onclick = function(){

    document.getElementById("AnotherHTML").innerHTML = "<p> Joe has a cat </p>";

}

```

That is all fine and well but there is a problem. How am I supposed to reuse this and keep it readable?... coming from a C++, I was always taught to write code in this way: 

```
function MyFunc()
{
           document.getElementById("AnotherHTML").innerHTML = "<p> Joe has a cat </p>";
}

document.getElementById("SomeHTML").onclick = MyFunc();

```

The latter code being cleaner (at least to me) and I can reuse the function, but it doesn't work ... I am able to write this way in every programming language yet in javascript it produces an error. I don't know what I am missing, I know its something simple. Can someone please help me understand why I cant write javascript functions in this way? Or if I can please tell me how, because I much prefer the latter than the former. thanx in advance.