I'm getting an illegal return statement in the line of my code near the bottom that says: return points
createPoints(x, y, length, depth, angle, points)
{
if(depth > 0)
{
//draws line
points.push((x + length) * Math.sin(angle));
points.push((y + length) * Math.cos(angle));
//draw left branch
angle += Math.PI / 4;
createPoints(treeString, (x + length/2) * Math.sin(angle), (y + length/2) * Math.cos(angle), depth - 1, points);
//goes back
points.push(x);
points.push(y);
//draw right branch
angle -= Math.PI / 2;
createPoints(treeString, (x + length/2) * Math.sin(angle), (y + length/2) * Math.cos(angle), depth - 1, points);
return points;
}
return;
}
the function is supposed to plot points in an array for a fractal tree to use in webgl. I'm not sure why I'm getting my error and unfortunately, neither my professor nor TA know either.
returnwithin a Function, you must declarecreatePointsas such, i.efunction createPoints(x, y, length, depth, angle, points) { // function body ... }. Check the MDN link about functions and to see alternative ways to declare one.