Ref: The problem appears because the snippet variable is not an object but an array.It seems to be a case of calling a method of some object X to object Y while they don't share the same method/properties i.e. An array object doesn't have a indexOf method