I am using an if statement and trying to make sure that it stops when it meets most of the conditions that it can. For example if I have the following code:
const determineLevel = () => {
const wentToKindergarten = true;
const wentToElementary = true;
const wentToHighSchool = true;
const wentToCollege = false;
if (wentToKindergarten) {
return 1;
}
if (wentToKindergarten && wentToElementary) {
return 2;
}
if (wentToKindergarten && wentToElementary && wentToHighSchool) {
return 3;
}
if (wentToKindergarten && wentToElementary && wentToHighSchool && wentToCollege) {
return 4;
}
return;
};
In this example, if a student went to kidergarten, elementary, and highschool but skipped out of college, how do I implement this? Right now, it just stops at the first condition it meets. Thanks!
Aucun commentaire:
Enregistrer un commentaire