vendredi 16 février 2018

If the condition of an if statement is true, can you stop execution?

If a condition is met, I want to be able to stop the execution of the program. This is a project for school, so I cannot change it from an IF statement.

    while (peopleInGroup[0] > i) {
        ageOfPeopleInGroup.push(prompt("How old are you? " + i));
        i++;
    }
    //If any one of the people in the group is under 13, then all members are prompted the rules of the movie thearter. If statements were choosen because it's possible none of the people in the group are under 13.//
    if (ageOfPeopleInGroup[0]< 13) {
        alert("If someone is under the age of 13, they must be accompanied by someone 18 years of age or older.")

Aucun commentaire:

Enregistrer un commentaire