Javascript AFrame loop error

Hello! I have been creating a funny copy of minecraft called “mine and craft” (not the exact same), and I was trying to make terrain generation with a loop. The script adds a 100 times in random a random spot (with x). But it gives me so many errors with it, and I am wondering why it is doing that.

Here is the code that is making the errors:

var scene = document.getElementById('yesyes'); // the scene in aframe
var grass = '<a-box rotation="-90 0 0" position="' + Math.floor(Math.random() * 100).toString; + ' 0 0" material="src:grass.png" height="1" width="1" repeat="1 1"></a-box>';
function terrainGenerate(){
  for(var a = 0;a < 100; a++){
    scene.innerHTML += grass

The full project is here:

- Dax

It should be .toString(), with parentheses

1 Like

Actually, you don’t have to convert integers before merging them to a string.
So removing the .toString should fix the bug!

1 Like