25. Printing using a for loop?


#1

Being a lazy guy, I had to attempt using a for loop to complete the exercise. I didn't get an error, but it also didn't print anything...

Here is the for loop in question.
for (var x=1; x===3; x++){
rabbit+x.describeMyself();
}

My question is this: how would I go about printing the describeMyself function for rabbit1, rabbit2 and rabbit3, without having the call them individually?


#2

Use console.log? :slightly_smiling:


#3

I should have probably specified that the describeMyself function had a console.log() in the code itself. So I was trying to figure out a way to call each variable (rabbit1, rabbit2, and rabbit3).describeMyself


#4

What I would do is use a different kind of for loop. Put the different rabbits into an array, and then iterate through it like so:
for(var rabbit in rabbits) {
rabbit.(method name)
}