### Snowflakes 004

Draws a grid of snowflakes with random twig lengths.

```// Forked from "Snowflake 003" by rupertxrussell
// https://turtletoy.net/turtle/8b68c0496b

// Forked from "Snowflake 001 " by rupertxrussell
// https://turtletoy.net/turtle/45cd645993

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

// Global code will be evaluated once.
const arms = 6; //min=4 max=10 step=1
const armLength = 10; //min=10 max=20 step=1
const numTwigs = 8; //min=3 max=10 step=1
const maxTwigLength = 3; //min=1 max=5 step=1
const minTwigLength = 1; //min=0 max=5 step=1
var twigLength;
const turtle = new Turtle();

let twig = [];
let XGap = 40; //min=20 max=50 step=1
let YGap = 40; //min=20 max=50 step=1

// calculate a random twig length for each twig
for(let j = 0; j < 200 - XGap ; j = j + XGap){

for(let k=0; k < 200 - YGap; k = k + YGap){

for (let nTwig = 0; nTwig <= numTwigs; nTwig ++){
twig[nTwig] = getRndInteger(minTwigLength, maxTwigLength);
}

for (let i = 0; i < arms; i++) {
turtle.penup();
turtle.goto(-100 + XGap + j, -100 + YGap + k);
turtle.pendown();
turtle.right(360/arms);

for(let n = 0; n < numTwigs /2 ; n ++){
turtle.forward(armLength / numTwigs);
turtle.right(60);
turtle.forward(twig[n]);
turtle.back(twig[n]);
turtle.left(60);

turtle.left(60);
turtle.forward(twig[n]);
turtle.back(twig[n]);
turtle.right(60);

turtle.forward(twig[n]);

turtle.right(120);
turtle.forward(twig[n+1]);
turtle.back(twig[n+1]);
turtle.left(120);

turtle.left(120);
turtle.forward(twig[n+1]);
turtle.back(twig[n+1]);
turtle.right(120);

turtle.forward(twig[n]);
turtle.back(twig[n]);
// turtle.right(360/arms);
// turtle.forward(twig[n]);
}
turtle.forward(twig[0]);  //
}
}
}

function getRndInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1) ) + min;
}```