# Printing Partial Name From Array

**URL:** https://discourse.processing.org/t/printing-partial-name-from-array/30630
**Category:** Beginners
**Created:** [June 10, 2021, 5:58pm UTC](https://discourse.processing.org/t/printing-partial-name-from-array/30630 "2021-06-10T17:58:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cottonchipper](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cottonchipper/32/10594_2.png) [@cottonchipper](https://discourse.processing.org/u/cottonchipper)
#### Post date: [June 10, 2021, 5:58pm UTC](https://discourse.processing.org/t/printing-partial-name-from-array/30630/1 "2021-06-10T17:58:11Z")

</div>

I’ve got an array made up of function names:

```auto
Gz = [Waterpump, Cyclotron, Conveyor, BoxDance, Tumblers, Giza, Lunar, Luxor, Trapeze, Sticks, Plus3, Bowtie, FourWalls, SquarePeg, Clockwork, Atomic, Batman, Robin, PolloLoco, Flo, Daddio, FourEyes, Spike, Wiperbot, Bloopy, Grimbot, PieFace];

print(Gz);

```

When I print out the contents of Gz[] it prints “function Waterpump(), function Cyclotron()…”

How would I print a list of the function names without the “function” preceding the name and the “()” following the name?

Here’s a link to an editor with the rest of the sketch: [https://editor.p5js.org/cottonchipper/sketches/zQ6JGhVIz](https://editor.p5js.org/cottonchipper/sketches/zQ6JGhVIz)

---

<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 10, 2021, 6:18pm UTC](https://discourse.processing.org/t/printing-partial-name-from-array/30630/2 "2021-06-10T18:18:08Z")

</div>

> **[Function.name - JavaScript | MDN](https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name)**
>
> A Function object's read-only name property indicates the function's name as specified when it was created, or it may be either anonymous or '' (an empty string) for functions created anonymously.

> **[Array.prototype.map() - JavaScript | MDN](https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)**
>
> The map() method creates
> a new array populated with the results of calling a provided function on
> every element in the calling array.

```auto
const functs = [setup, draw];
const functNames = functs.map(funct => funct.name);

function setup() {
  noLoop();
  print(functs);
  print(functNames);
}

function draw() {
  background('blue');
}

```

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [June 10, 2021, 6:22pm UTC](https://discourse.processing.org/t/printing-partial-name-from-array/30630/3 "2021-06-10T18:22:37Z")

</div>

```auto
for (let i = 0; i < Gz.length; i++) {
  print(Gz[i].name);
}

```

---

<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 10, 2021, 6:24pm UTC](https://discourse.processing.org/t/printing-partial-name-from-array/30630/4 "2021-06-10T18:24:51Z")

</div>

> **[for...of - JavaScript | MDN](https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of)**
>
> The for...of statement creates a loop iterating over iterable
> objects, including: built-in String, Array, array-like
> objects (e.g., arguments
> or NodeList), TypedArray, Map,
> Set, and user-defined iterables. It invokes a custom iteration...

- `for (const funct of Gz) print(funct.name);`
- `for (const { name } of Gz) print(name);`

---

<div class="post-metadata">

### Author: ![cottonchipper](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/cottonchipper/32/10594_2.png) [@cottonchipper](https://discourse.processing.org/u/cottonchipper)
#### Post date: [June 10, 2021, 6:33pm UTC](https://discourse.processing.org/t/printing-partial-name-from-array/30630/5 "2021-06-10T18:33:41Z")

</div>

Thank you both for the help!
