The type of object that we get back from getEntitiesByTag is an Array, which is a list of elements that you can access by number. To test that we are finding entities that have a matching tag, we’ll ask the console to tell us the name of the first entity in the list, which will be entity number 0.
- In the randomizeTreasure function, create an if-statement that checks that digSpots is not null.
- Inside the if-statement, log digSpots.name to the console.
- Call the randomizeTreasure function in the start function temporarily so that we can see it run when the game starts.
- Press Stop and Play and see what shows up in the Dev Tools Console.