9. 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.

9.1. Question 1: Checking the range constraint of an enumeration 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();

9.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 = ______________;