# Num undefined, no messages

**URL:** <https://discourse.processing.org/t/num-undefined-no-messages/813>\
**Category:** p5.js\
**Created:** [June 9, 2018, 7:17pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813 "2018-06-09T19:17:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serge](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Serge](https://discourse.processing.org/u/Serge)\
**Post date:** [June 9, 2018, 7:17pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813/1 "2018-06-09T19:17:32Z")

</div>

[https://p5js.org/examples/structure-functions.html](https://p5js.org/examples/structure-functions.html)

in this example num is use but is not defined

What is this num variable? argument not defined? else?  
Here is the code:

```auto
function setup() {
  createCanvas(720, 400);
  background(51);
  noStroke();
  noLoop();
}

function draw() {
  drawTarget(width*0.25, height*0.4, 200, 4);
  drawTarget(width*0.5, height*0.5, 300, 10);
  drawTarget(width*0.75, height*0.3, 120, 6);
}

function drawTarget(xloc, yloc, size, num) {
  var grayvalues = 255/num;
  var steps = size/num;
  for (var i = 0; i < num; i++) {
    fill(i*grayvalues);
    ellipse(xloc, yloc, size - i*steps, size - i*steps);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Trilobyte](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/trilobyte/32/361_2.png) [@Trilobyte](https://discourse.processing.org/u/Trilobyte)\
**Post date:** [June 9, 2018, 8:11pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813/2 "2018-06-09T20:11:20Z")

</div>

@Serge  
I’m not sure I’m understanding your post. Is there a problem with the code, or are you just wondering what type of variable “num” is? The code looks identical to the example code.

- Trilobyte

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [June 9, 2018, 8:31pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813/3 "2018-06-09T20:31:22Z")

</div>

`num` is the last argument passes to the `drawTarget()` function:

```
function drawTarget(xloc, yloc, size, num) {

```

When this function is called, four arguments are passed in. For example, in the first call:

```
drawTarget(width*0.25, height*0.4, 200, 4);

```

The four arguments that get passed in are:

1. `width*0.25`
2. `height*0.4`
3. `200`
4. `4`

So in this case, `num` will have the value of 4.

---

<div class="post-metadata">

**Author:** ![Serge](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Serge](https://discourse.processing.org/u/Serge)\
**Post date:** [June 9, 2018, 8:55pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813/4 "2018-06-09T20:55:21Z")

</div>

It seems there is no need to declare them

Thank you

---

<div class="post-metadata">

**Author:** ![Serge](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Serge](https://discourse.processing.org/u/Serge)\
**Post date:** [June 9, 2018, 8:56pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813/5 "2018-06-09T20:56:30Z")

</div>

Was wondering about not declaring argument as variable

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 9, 2018, 9:42pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813/6 "2018-06-09T21:42:36Z")

</div>

Some pedantic observations: 🧐

1. **Parameter** is a variable declared inside a function’s parentheses.
2. **Argument** is the value passed to a function’s parameter.
3. In JS, parameters are declared w/o any keywords; such as `var`, `let` or `const`.

---

<div class="post-metadata">

**Author:** ![Serge](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Serge](https://discourse.processing.org/u/Serge)\
**Post date:** [June 9, 2018, 9:49pm UTC](https://discourse.processing.org/t/num-undefined-no-messages/813/7 "2018-06-09T21:49:17Z")

</div>

Thank you for the information
