How can researchers take this possible confounding variable into account?

How can researchers take this possible confounding variable into account?

Background: It is thought that gender may be a confounding variable in the relationship between sugar intake and activity level.

Question: How can researchers take this possible confounding variable into account?