Hello, I’m having trouble understanding how and why something is defined…
I have a switch statement, that based on a random number would give different values:
switch (_.random(1,3)) {
case 1:
roleId = 8;
roleName = "Coach";
roleRegistrationGroup = "COACHES";
break;
case 2:
roleId = 7;
roleName = "Industry Expert";
roleRegistartionGroup = "Experts";
break;
case 3:
roleId = 4;
roleName = "Ovals";
roleRegistartionGroup = "OVALS_OVALS";
break;
}
Now, when I run it, it returns successfully the value for roleId, roleName, however "roleRegistartionGroup " works only for case 1, the rest it says its not defined. Should I define the variables before the switch statement?
Also why does it only happen after case 1?
EDIT : Well apparently I’ve misspelled roleRegistration for all other cases.