How does a jellyfish know what they are doing with no brain?

Essentially, we would presume that a jellyfish would not know or think about what it's doing. A jellyfish would go on its instincts. You have to remember that a jellyfish still has neurons, but it will not have a center of control of these neurons (which we call the brain). Thus, the jellyfish would not think to attack another fish and eat it, its neurons will simply react to the closeness of a fish and engage the jellyfish in this behaviour of killing and eating its pray. It is done pretty automatically.
However, I do not know if the jellyfish would be able to learn with no brain. It can adapt to the environment, but can we make it learn specific behaviours??

So basically jellyfish are like robots, they run on autopilot.