# JavaScript Basic Question

**URL:** https://discourse.processing.org/t/javascript-basic-question/8434
**Category:** Coding Questions
**Created:** [February 16, 2019, 1:42am UTC](https://discourse.processing.org/t/javascript-basic-question/8434 "2019-02-16T01:42:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ixd](https://avatars.discourse-cdn.com/v4/letter/i/41988e/32.png) [@ixd](https://discourse.processing.org/u/ixd)
#### Post date: [February 16, 2019, 1:42am UTC](https://discourse.processing.org/t/javascript-basic-question/8434/1 "2019-02-16T01:42:24Z")

</div>

How can I make it so that the grass is “cut” at a certain height?

I think I should be changing something in line 21, but not sure… also, when the grass is cut, all that happens is a white rectangle is being placed over it

```auto
function setup() {
  createCanvas(400, 200);
  colorMode(HSB);
}

var x = 0;
var h = 10;

function draw() {
  stroke(random(60, 70), 100, 90);
  line(x, height-10, x+random(-10, 10), height-10-random(h));
  noStroke();

  x = x + 10;

  if (x > width) {
    x = random(10);
    h = h + 3;
  }

  if (random() > 0.999) {
    fill(255);
    rect(0, 0, width, height-15);
    h = 10;
  }

  fill(40, 100, 60);
  rect(0, height-10, width, 10);
}

```

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [February 16, 2019, 2:29am UTC](https://discourse.processing.org/t/javascript-basic-question/8434/2 "2019-02-16T02:29:18Z")

</div>

```auto
  if (random() > 0.995) { 0.999
    fill(255);
    rect(0, 0, width, height-25); //15);
    h = 10;
    console.log("cut");
  }

```

well, the grass is cut at at certain height already,  
you see that you have the ground area at  
height - 10  
and the cut above  
height - 15  
so you see some short grass after cut.  
you can change the height like i show,  
same you can change how often the grass is cut,
