# Solving an Unexpected Identifier

**URL:** <https://discourse.processing.org/t/solving-an-unexpected-identifier/13645>\
**Category:** Coding Questions\
**Created:** [August 27, 2019, 11:38am UTC](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645 "2019-08-27T11:38:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VMK](https://avatars.discourse-cdn.com/v4/letter/v/919ad9/32.png) [@VMK](https://discourse.processing.org/u/VMK)\
**Post date:** [August 27, 2019, 11:38am UTC](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645/1 "2019-08-27T11:38:17Z")

</div>

Greetings!  
I’m trying to create a class to draw a bezier curve but seeing ‘unexpected identifier’ error which doesn’t make sense to me : [http://tiny.cc/xy7sbz](http://tiny.cc/xy7sbz)

[https://editor.p5js.org/VMK/sketches/D-GpdoGiM](https://editor.p5js.org/VMK/sketches/D-GpdoGiM)

Any help would be highly appreciated, thank you!

```auto
var activitesCurve = function(bzCurve) {
  bzCurve.setup = function() {
    var run = [25, 50, 60, 70];
    var walk = [15, 75, 80, 40];
    bzCurve = new BzCurve();
  }
  bzCurve.draw = function() {
    bzCurve.show();
    class BzCurve {
      constructor() {
        this.stroke = (239, 31, 193);
        this.margin = 50;
        this.height = bzCurve.windowHeight;
        this.arr = run;
        this.maxLength = run.length;
        this.pointGap = position;
      }
      show() {
        bezierCurve.stroke(this.stroke);
        bezierCurve.beginShape();
        bezierCurve.vertex(this.margin, this.height / 2 - this.arr[0]);
        for (int i = 1; i < this.maxLength; i++) {
          var posX = bezierCurve.float(i * this.pointGap + this.margin);
          var posY = bezierCurve.float(this.height / 2 - this.arr[i]);
          var c1 = bezierCurve.float((i - 1) * this.pointGap + this.margin);
          var c2 = bezierCurve.float(this.height / 2 - this.arr[i - 1]);
          var c3 = posX;
          var c4 = posY;
          bezierCurve.bezierVertex(c1, c2, c3, c4, posX, posY);
        }
        bezierCurve.endShape();
      }
    }
  }

  // Walk Line
  bezierCurve.stroke(23, 225, 0);
  bezierCurve.beginShape();
  bezierCurve.vertex(margin, height / 2 - walk[0]);
  for (int i = 1; i < walk.length; i++) {
    var posWX = bezierCurve.float(i * pointGap + margin);
    var posWY = bezierCurve.float(height / 2 - walk[i]);
    var cW1 = bezierCurve.float((i - 1) * pointGap + margin);
    var cW2 = bezierCurve.float(height / 2 - walk[i - 1]);
    var cW3 = posWX;
    var cW4 = posWY;
    bezierCurve.bezierVertex(cW1, cW2, cW3, cW4, posWX, posWY);
  }
}

var activitiesSketch = new p5(activitesCurve, 'activities');

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 27, 2019, 5:33pm UTC](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645/2 "2019-08-27T17:33:06Z")

</div>

> [@VMK](#):
>
> for (int i = 1; i \< this.maxLength; i++) {

“int i”? What is an “int”? It seems like some kind of identifier, but I’m a JavaScript parser, so that is pretty unexpected. 😉

---

<div class="post-metadata">

**Author:** ![VMK](https://avatars.discourse-cdn.com/v4/letter/v/919ad9/32.png) [@VMK](https://discourse.processing.org/u/VMK)\
**Post date:** [August 27, 2019, 6:57pm UTC](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645/3 "2019-08-27T18:57:48Z")

</div>

Ah yes! you’re right, Jeremy, that did the trick.  
I initially had this code in processing and then translated to P5js  
So now that’s solved, I’ve run to another issue 😒 : [http://tiny.cc/c5wtbz](http://tiny.cc/c5wtbz)  
Pretty sure I’m not mistaken in defining the class here. What am I missing? Kindly advice? Thank you!

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [August 27, 2019, 9:53pm UTC](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645/4 "2019-08-27T21:53:19Z")

</div>

Just glancing at it, it looks like you have defined it as an inner class. So it isn’t in scope when you call new. Put the class definition at the top level of the sketch.

---

<div class="post-metadata">

**Author:** ![VMK](https://avatars.discourse-cdn.com/v4/letter/v/919ad9/32.png) [@VMK](https://discourse.processing.org/u/VMK)\
**Post date:** [August 28, 2019, 12:25pm UTC](https://discourse.processing.org/t/solving-an-unexpected-identifier/13645/5 "2019-08-28T12:25:15Z")

</div>

Thanks for the response, Jeremy!  
The class was inside the draw function 🤫
