I have a task in my JavaScript class where I need to create a script to generate an object. The issue I am facing is that I want to restrict the possible values of a property in my object. Below is the code snippet:
var StudentObject = new Object();
var StudentStatus = new Object();
StudentStatus ={
paid:true,
registrationOK:true
}
StudentObject = {
status: StudentStatus,
track: "",
course:"Applied Informatics"
}
In the "StudentObject" object, there is a property called "track". I want to limit its value to either "MBT" or "PBT". Is there a simple way to achieve this?
Appreciate your help.