I'm trying to combine two of my codes which are identical, they only differ in the event handler. When the website is loaded it fires up my functions and if the user resizes it's browser it will update the variables and runs the function again.

```
$(window).load(function() {

        $(!agent) {

            var milk   = $().height(),
                choco  = $().width();

            doThis();

        } else {
            var orange  = $().length(),
                apple   = $().width();

            orThis();
        }

});

$(window).resize(function() {

        $(!agent) {

            var milk   = $().height(),
                choco  = $().width();

            doThis();

        } else {
            var orange  = $().length(),
                apple   = $().width();

            orThis();
        }

});

```