Comparing two objects

I am making a snake game and trying to make sure that the the the food item does not have the same coordinates as the snake. As a result, I tried something inside createSnake() function. Am I doing it properly for this game? If not what should I do?

A post was merged into an existing topic: Struggling with snake game