I managed to get past the level “Chain of Command” on my own, well with a little help from the “Hints” section on the level. I understand that the code:
This is code that is already written for you in Python before you actually input anything, still learning all the rules of the forum yet, but I don’t think this breaks any of them or at least am hoping it doesn’t.-
def barkForMaster(event): # "hear" events set the event.speaker property. # Check if the pet has heard the hero: if event.speaker == hero: pet.say("WOOF")
is for to specify the event for the pet to only happen when set off by the specified target (hero). What I didn’t and still don’t understand is arrays, and I mean pretty much anything at all about them. The research suggested by the definition by hovering over “arrays” and the source it suggested I go to for better understanding (Mozilla’s Array Documentation) has failed to quite drill it into my skull what and how arrays work.
I’m figuring that I’m either overlooking something simple or am thinking too hard about it, but I’m at a loss for what it might be. The only things I learned about arrays in this level was I could use arrays to determine factors of some sort or another such as length and use it as a variable possibly, (Yes, I know even my explanation is shaky at best) that for some reason brackets “” are needed for them instead of “.”, and that arrays are in some way useful for possibly organizing/ordering certain factors (which I still think I fail to grasp). The only reason I was able to get past the level with the correct line of code involving arrays was because the answer was literally within the “Hints”, which I try to avoid looking at unless I’m stumped completely about what I am supposed to do.
So, what I am asking in short is three questions:
With the level “Chain of Command”, should I already understand arrays by this point, or just be learning about them?
Can someone either help me or direct me to one or more places that could help me learn and understand arrays, how to properly use them, and how they work?
Is anything I think I understand about arrays even close to being on the right path?