For example if I define a function such as
$f(x) = x^2$
then set the domain to be {$x|x\in\mathbb{Z}$}
it follows then, that the range is {$f(x)|f(x)\in\mathbb{Z^+}$}
from my understanding of the codomain, it is defined by us when we create a function, therefore in this case would the codomain of the function be undefined, as we haven't set it or would it be $\mathbb{Z}$ or $\mathbb{Z^+}$