New course! Every coder should learn Generative AI!
Try a free lesson0
Exercise “Male or female”
Please tell me the solution options. Language does not matter Determine if the sex of the offspring will be male or female based on the X or Y chromosome present in the male's sperm. If the sperm contains the X chromosome, return "Congratulations! You're going to have a daughter."; If the sperm contains the Y chromosome, return "Congratulations! You're going to have a son.";
1 Answer
+ 2
JS:
something like this
const x;
const y;
function getSex(chromosome) {
if (chromosome === x) {
alert("Congratulation! You're going to have a daughter!");
} else if (chromosome === y) {
alert("Congratulations! You're going to have a son!");
}
}