# Passing parameters to function and avoiding duplicate variable definitions

**URL:** https://forum.kirupa.com/t/passing-parameters-to-function-and-avoiding-duplicate-variable-definitions/290696
**Category:** Uncategorized
**Created:** [June 18, 2009, 12:44pm UTC](https://forum.kirupa.com/t/passing-parameters-to-function-and-avoiding-duplicate-variable-definitions/290696 "2009-06-18T12:44:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lope](https://avatars.discourse-cdn.com/v4/letter/l/43a26b/32.png) [@lope](https://forum.kirupa.com/u/lope)
#### Post date: [June 18, 2009, 12:44pm UTC](https://forum.kirupa.com/t/passing-parameters-to-function-and-avoiding-duplicate-variable-definitions/290696/1 "2009-06-18T12:44:43Z")

</div>

I have shortened this example to keep it simple, otherwise I wouldnt be doint this 😃

I need to pass different variables to function **inForLoop** each time.

```auto
function someFunction():void {
    for (var i:int = 0; i < columns; i++) {

        for (var j:int = 0; j < rows; j++) {

            inForLoop(i, j);//this is fine

        }
    }
    for (var m:int = 0; m < columns; m++) {

        for (var n:int = 0; n < rows; n++) {

            inForLoop(m, n);//ofcourse function inForLoop wouldnt accept this

        }
    }
    for (var p:int = 0; p < columns; p++) {

        for (var r:int = 0; r < rows; r++) {

            inForLoop(p, r);//nor this

        }
    }
}

function inForLoop(i:uint, j:uint):void {

    holder.x = i * IMAGE_PIECE_WIDTH;
    holder.y = j * IMAGE_PIECE_HEIGHT;

}

```

How could I make this work?
