10. Quiz Questions

If you would like to look up the answers to the following quiz questions, you can check our discussion forum. If you don't find an answer in the forum, you may create a post asking for an answer to a particular question.

If you would like to do interactive quizzes with online feedback and with the option to ask a coach, then you should enrol in the introductory online course (book parts 1-3) offered by our partner developer-competence.com.

10.1. Question 1: Checking the Range Constraint of an Enum Attribute

Complete the following code fragment for checking the range constraint of the enumeration attribute gender with range GenderEL:

Person.checkGender = function (g) {
  if (!Number.isInteger(g) || g < 1 || g > _______) {
    return new RangeConstraintViolation("Invalid gender value!");
  } else {
    return new NoConstraintViolation();
  }
};

10.2. Question 2: Computing MAX

Complete the following code fragment for computing the special enumeration literal MAX as in the proposed Enumeration class:

function Enumeration( enumLabels) {
  this.MAX = ______________;
  ...
}