Could I know why doesn't this code work? Thanks.
Might be an extra tab/space before "photo"
The error tells us that `photo` is not an object, literally. So that must mean either the photoCollectionArray is empty, or it has elements in it that are not Layers.
It's hard to know without more code.