Question: I can't figure out how to re-use large chunks of code.

I thought it would be like this:

```
function bulkCode() {
    ... large amount of code
}

$(document).on('click', function() {
    ...blah...

    bulkCode();
});

```

I have a selection of code I want to use over three different areas, and I am sure there is a way to re use the code without pasting it in each one...

Can anyone give me an example of how to do this?

Answer: 
In order to use your local variables:

```
var urlHead = '/portfolio/embed-head-view/'+entry+'/'+category;
var urlImage = '/portfolio/embed-image-view/'+entry+'/'+category;
var urlDetails = '/portfolio/embed-details-view/'+entry+'/'+category;

```

you have to define your function as:

```
function imageLoad(urlHead, urlImage, urlDetails){ ... }

```

and call it by passing the parameters:

```
imageLoad(urlHead, urlImage, urlDetails);

```
You could put the code in a .js file and include it in the page with a script tag like the following.

```
<script src="path/jsFile.js"></script>

```