Just check the remainder of division by 10:
if (day % 10 == 1) {
result = "dan";
} else {
result = "dana";
}
% is the “Modulo” or “Modulus” Operator, unless you’re using JavaScript, in which case it is a simple remainder operator (not a true modulo). It divides the two numbers, and returns the remainder.