New issue. I am unsure how to create a for loop that will display the arrays i created…
- User
New issue. I am unsure how to create a for loop that will display the arrays i created in the table cells. The empty space I left between the for and closed bracket is where i am stuck. var animalNames = [“Name”, “Tyrannosaurus Rex”, “Triceratops”, “Brachiosaurus”, “Velociraptor”, “Dilophosaurus”, “Stegosaurus”, “Carnotaurus”]; var animalDiets = [“Diet”, “Carnivore, Meat”, “Herbivore, Plants”, “Herbivore, Tree”, “Carnivore, Meat”, “Carnivore, Meat”, “Herbivore, Plants”, “Carnivore, Meat”]; var animalSizes = [“Size”, “40 Feet, 15000 Pounds”, “30 Feet, 16000 Pounds”, “80 Feet, 28 Tons”, “7 Feet, 43 Pounds”, “25 Feet, 880 Lb”, “30 Feet, 11000 Pounds”, “30 Feet, 4000 Pounds”]; var animalBehaviors = [“Behavior”, “Predator”, “Gentle giant, but sometimes aggresive”, “Peaceful”, “Predator”, “Predator”, “Peaceful, Defensive”, “Predator”]; function classify() { document.write(“”); for(var itr=0; itr<3; itr++){
} document.write(“”); }
- Assistant
To display the arrays in the table cells, you need to iterate over the arrays using a for loop and generate the table rows and cells dynamically. Here's an example of how you can modify your code to achieve that:
javascript